January 4th, 2013, 05:54 PM
Working on php 5+ and mysql5+. I intend to start using mysqli and OOP as soon as I can learn it. My question is how much time do I have before making the change? And, will I have to eventually have to rewrite projects that used mysql? I've been digging around and can't find out if Mysqli is going to replace mysql or just work alongside it as an option. If not, how long do I have to learn all this? Thank You
January 4th, 2013, 06:35 PM
Whatever its merits, I can't see OOP completely replacing procedural code any time soon.
However, the 'mysql' method is, as you suggest, slowly being superseded by alternative methods of PDO and MySQLi.
These methods are more secure than the traditional method, with (mostly) negligible effects on performance.
To my understanding, characteristics of each are as follows:
- suitable for both OOP and procedural environments
- MySQLi is tied to MySQL
- very similar usage to the traditional mysql method
- suitable for OOP
- not wedded to any particular SQL engine
Others will of course come to a different conclusion, but I make that 2-1 (or 3-2) in MySQLi's favour.
So you don't need to rush to learn OOP - but that's no reason not to start!
January 4th, 2013, 06:43 PM
The PHP-MySQL API will be removed some day, but not soon. However, it's also no longer being updated, so any features it doesn't support now will never be supported (async. queries, prepared statements, stored procedures, multi-queries, etc.) and any new featured that are added to MySQL won't be supported ever. So for this reason, all new code should use MySQLi or PDO.
What will likely happen, is that in 5-10 years the MySQL extension will become disabled by default in PHP. Then in another 10-20 years web hosts will stop installing it.
January 4th, 2013, 07:18 PM
Thank you for your thoughtful replies