homepage Welcome to WebmasterWorld Guest from 54.211.0.191
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PDO() or mysqli()?
CSS_Kidd




msg:4320176
 8:10 pm on May 31, 2011 (gmt 0)

I know this may be a can of worms but I got to ask.

In my process of learning and expanding on PHP, I have gone through three very helpful books. But when it came to database instructions, two of them guided me using mysqli() and one using PDO(). Don't get me wrong, I love learning new stuff. But this is just annoying. I guess I would like to get an overall opinion of the following:

How will I know which one to use?
Which is easier to migrate?
Which can be referred to more as "standard"?
What are the benefits of either/each one?
and of course,
Why must life be so complicated?

 

jbroder




msg:4320263
 12:17 am on Jun 1, 2011 (gmt 0)

Databases are fairly interchangeable. So don't worry about it too much.

I could be wrong, but I think the standard is mysql (not mysqli).

Sorry to complicate matters further. :)

If I were learning from scratch, I would just get started on a project. Learning from books doesn't work unless you have a project to make the lessons stick in your mind. So if you don't have a host yet, just pick a host and use whatever database they have. It will probably be mysql.

Have fun.

coopster




msg:4320474
 1:27 pm on Jun 1, 2011 (gmt 0)

If you already have your own consistent interface for accessing databases in PHP then considering PDO may end up being more work for you. Remember that "PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction..."

Many developers write their own abstraction class which mimics that which you see in PDO. For example, I wrote one before PDO had support for the mysqli functions which I use (the "i" in mysqli stands for "improved" and is the preferred API for MySQL >= version 4.1; see mysqli overview for details [php.net])

CSS_Kidd




msg:4323398
 12:35 pm on Jun 8, 2011 (gmt 0)

Without going through the hassle of writing my own abstraction class, would PDO still be a good thing to learn up on? Especially when the server administrator informs you that they use.. let's say Postgresql instead of mysql? Which they kindly forgot to inform me of.

coopster




msg:4323537
 5:30 pm on Jun 8, 2011 (gmt 0)

Knowledge is one thing, application another. I love to learn and have learned and tinkered with PDO but I don't use it. If it is what your server admin says you are going to be using I imagine it would be a good thing to learn and apply. Just some more food for thought!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved