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
https://forums.phpfreaks.com/topic/219683-pdo-vs-mysql_connect-vs-mysqli/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.