Hi,
I have gone over and over the subject and still confused.

I currently develop in PHP 5.2.x along with MySQL. (awaiting host to upgrade to 5.3.x, hopefully not to long although on local i develop using php 5.3.5)

Currently i use the standard MySQL functions in PHP like:

mysql_connect(), mysql_fetch_array(), mysql_num_rows(), mysql_fetch_row() etc.

Now i want to improve on the above. I have MySQLi, PDO etc enabled on my local and web hosting server and was going to just change all mysql_ with mysqli_.

Then i started reading about PDO, OOP, Prepared Statements.

Now i have no knowledge of PDO, OOP, Prepared Statements and MySQLi.

Could someone please recommend what i should be going for? i mean i gather from what i read they are all different in certain ways. I seem to be reading allot about PDO anpd eople recommending it, then i hear about prepared statements, is prepared statements the same as PDO and MySQLi same as PDO and prepared statements?

I am so confused even thou i have been reading all about them on php website and in google search results and not sure which one i should be using. I mean i don't want to be behind with times plus i want to improve my skills and keep up to date.

If someone could please explain which i should be going for and if PDO is different from prepared statements etc that would be great.

I just cannot grasp my head around it all. Not matter how much searching i have done i cannot seem to find an exact answer to my question(s).

Thanks

Recommended Answers

All 2 Replies

Prepared Statements are a mechanism/feature to prevent sql injection.
PDO, mysql, mysqli are "software layers" that allow you to interact with the db server, but not all of them support prepared statements.

-only PDO and mysqli support prepared statements.
-mysql and mysqli can be used only with mysql database server
-pdo can be used with various db servers

I prefer to use PDO since it does support prepared statements and it gives me the flexibility to potentially change to a new host where the db server might NOT be mysql but say postgresql.

Hello,

Thanks for this, something so simply written has cleared allot up in my head :)

Time to learn PDO :/

Thanks! +1 for you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.