Jump to content

MySQL or MySQLi


phppup

Recommended Posts

MySQL was removed from PHP.

 

Your choices are either Mysqli or PDO with the MySQL driver.

 

The consensus opinion of the vast majority of our staff and experienced php developers, is that PDO is easier to work with and better designed.

 

There is a complete and highly opinionated manual for using PDO here: https://phpdelusions.net/pdo

 

If you peruse that site, you'll also find a manual for using mysqli: https://phpdelusions.net/mysqli

 

I don't remember the exact location but there are places where there's some comparison between the two, particularly in support of binding parameters with a 'WHERE IN' queries.

 

In both cases, the common practice of creating SQL strings using PHP interpolation and user input is something that you no longer will want or need to do.

Link to comment
Share on other sites

I don't know if I have gotten so deep as to be "creating SQL strings using PHP interpolation" but I guess I'll have to investigate.

 

Meanwhile, will "old" PHP code utilizing a MySQL database still function, or are there modifications required.

Link to comment
Share on other sites

In my opinion the switch is not necessarily painful, but it depends on the size and scope of the original code. If you have lots and lots of existing mysql_ queries all over the place, you have to go through them, and while cut and dried, it still might take a while.

 

If you perhaps have a database wrapper class, things could be a lot easier.

 

Either way, once you have the jist of the differences, it's not complicated, but perhaps time consuming. At that point it also might be work retrofitting in a database wrapper like Doctrine2, and converting everything to DBAL calls.

Link to comment
Share on other sites

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.