July 29th, 2013, 03:09 PM
Should I start using mySQLi
I'm going to start creating a simple website for my company where the end user logs in and enters data into some input boxes. Because I'm researching the login and password page I noticed some articles about PHP deprecating mySQL. I also posted a question about some of my code and they told me to stop using mySQL and switch to mySQLi.
My web hosting company is GoDaddy and the PHP version is 5.3.
What should I do? If I do it with mySQL will my website stop working whenever PHP decides to "turn off" mySQL?
Thank you for your help and guidance.
July 29th, 2013, 03:23 PM
The mysql_* functions have long gone unmaintained so there are questions surrounding their security, among other things. And yeah, when they're removed from PHP any scripts using them will cease to work.
If you're writing a new application there's really no reason at all not to switch to mysqli_* or PDO. PDO seems to be the more popular option around here since it can be an interface to many different database engines, and the prepared statement syntax is a little nicer. mysqli is obviously going to be MySQL-specific and while it can do prepared statements, the syntax is less flexible.
July 29th, 2013, 07:35 PM
The mysql extension is officially deprecated as of PHP 5.5, but it is still being maintained. The implementation of the mysql_* functions themselves are not insecure, they are just difficult to use securely and lack support for a significant number of features. When the extension is removed (which will happen eventually), any applications relying on it will cease to function and most will probably require a substantial amount of effort to fix. There is absolutely no reason to build a new application using the mysql extension; I recommend the PDO extension instead.
As far as the mysql extension itself goes (for people already using it who are wondering), it should continue to be maintained until at least July 2014, and probably into 2015. Because the extension is not deprecated in 5.4, maintenance releases for it should continue until at least the EOL date for 5.4 (which isn't set yet). Given the widespread use of the extension, I would not actually be surprised to see continued maintenance releases for it even after 5.4 reaches EOL.
As far as removal from the language, I would guess that will happen in 5 - 10 years. register globals and magic quotes were both removed after having been officially deprecated for about 2 years, but both had been unofficially deprecated for about 10 years. The mysql extension has already been unofficially deprecated for a couple of years as well because many people knew it would be deprecated soon. I would not be surprised to see the extension officially removed as of PHP 6.
July 30th, 2013, 09:12 AM
Thank you to the both of you for your help. I will use PDO instead of mySQLi.