Jump to content

PDO vs mysql_connect vs mysqli


johnsmith153

Recommended Posts

I am trying to extend my knowledge from using basic mysql_connect etc. into something better.

 

I am searching on Google, and looking up as much info as possible but find that I learn best with a brief overview that allows me to channel down my searches.

 

(1) I know PDO v mysql_connect v mysqli isn;t right - I think PDO is a class, mysql_connect is a command and mysqli is something else. Am I on the right track?

 

(2) What is the best solution? I am using a full OOP coding style and want to learn the best - I am a novice at this but would consider myself an 8/10 programmer at other parts of PHP.

 

An very brief overview to get me started and channel my Google searches would be much appreciated.

 

- I have heard PDO is slower.

- I don't need support for different databases (only MySQL).

 

Thanks in advance.

Link to comment
Share on other sites

(1) I know PDO v mysql_connect v mysqli isn;t right - I think PDO is a class, mysql_connect is a command and mysqli is something else. Am I on the right track?

 

Not at all. mysql_connect is a function (commands are what you execute at prompt to tell a computer what to do) belonging to the mysql extension. mysqli is another (newer) improved mysql extension which offers both a procedural and object oriented interface.

 

PDO is different in that it offers an object oriented interface to a variety of database drivers (including MySql).

 

(2) What is the best solution? I am using a full OOP coding style and want to learn the best - I am a novice at this but would consider myself an 8/10 programmer at other parts of PHP.

 

I have seen some of your code and would not call it OOP. You use classes and objects yes, but are not designing around OOP design patterns. Having said that, if its OOP you want to get into (and even if its not), PDO is probably a good option. While it doesn't (by itself) provide a complete abstraction from different database implimentations, it can get you a good part of the way there.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.