10

I was reading this question: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

And it got me thinking that I should make the change from mysql to mysqli. It is a one character change in CodeIgniter so it isn't very hard :)

But is there anything I should look out for to spot any errors that can happen? Are there certain queries that are treated differently?

YakovL
  • 7,557
  • 12
  • 62
  • 102
Chris Muench
  • 17,444
  • 70
  • 209
  • 362

1 Answers1

9

Are there certain queries that are treated differently?

No.

The MySQL and MySQLi extension are “drivers” that take care of the communication between PHP and the MySQL database server;

they do not change the range of SQL commands that the MySQL server understands.

So as long as the DB abstraction layer takes care of what PHP functions are to use for what purpose for you (and a framework like CI should most certainly do that), there is nothing to worry about in regard to the actual queries.

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • Great, I feel more confortable making the switch – Chris Muench Feb 04 '14 at 01:06
  • @CBroe Sir, I have existing programs/ systems right now and when i learn about the depreciation of mysql in the future i decided to switch to mysqli with the new projects and leaving the old as mysql. Is that good/ okay that i may just leave the old systems running or should i convert/ switch them too? If ever it's better to switch the old systems to mysqli, what would be the easiest/ simpliest to do that? Do i have to replace mysql to mysqli per page of the system? – Aljie Feb 04 '14 at 02:49
  • @Aljie: Well, “never touch a running system” is a basic IT rule, isn’t it? :-) But once MySQL extension support will be completely dropped from PHP, you won’t be able to run your scripts on a current, up-to-date PHP install any more. If you’re in control of the general system architecture, it’s your decision whether that’s a risk worth taking – in comparison to the threats it might pose and the cost of updating your scripts. – CBroe Feb 04 '14 at 02:55
  • While you can _quite_ simply go from MySQL to MySQLi by manually adapting your code (no need to switch to prepared statements for example, and you can keep it all procedural style), it’s no as easy as running a simple string-replace on your script directory, because for most of the functions the order of parameters has changed (in general the procedural MySQLi functions require the connection identifier as first parameter). – CBroe Feb 04 '14 at 02:57
  • 2
    I guess thats what is nice about using a database abstraction layer. If done right, it is easy. After I upgraded my codeigniter app, I had to update my website, which didn't use any abstraction layer. It look me about 4-5 hours to upgrade and test every function again. it was a pain, but I feel better after doing it! – Chris Muench Feb 04 '14 at 02:58