Jump to content

The plot to kill PHP - MySQL extension


Recommended Posts

The Plot

Yes, you read it right. Recently, Phillip Olson sent to the PHP internals mailing list a proposal to kill the original PHP MySQL extension in future PHP versions.

Well, as you may have read, the idea is not to kill this very popular PHP extension right now in the upcoming PHP 5.4.

The idea is to first mark its functions as deprecated in the PHP documentation. The intention is to educate PHP developers to migrate their code to use the mysqli or the PDO extensions instead, or the mysqlnd, why not?

In future versions, say PHP 5.5 or 5.6 common calls to functions like mysql_pconnect, mysql_query, etc.. will throw ugly E_DEPRECATED notices. And eventually in PHP 6 or later, if it will ever happen, code that uses those functions will be removed from the main PHP distribution permanently.

The PHP 5 adoption fiasco all over again?

Well, you know, despite PHP 5.0 was released in 2004, it was not until 2008 when PHP 4 was officially considered discontinued, that it started gaining serious adoption. Despite PHP 5 contained a plethora of new features, many, many PHP developers refused to upgrade from PHP 4 to PHP 5 until they were forced to do it.

PHP 5 was mostly backwards compatible with PHP 4. So what was wrong with PHP 5? Many details, but I think I can sum it up to not being 100.0% compatible with PHP 4. Nobody wants to change code that just works.

In many cases, code that was running well in PHP 4, would still run well on PHP 5, except that it would probably throw many deprecated syntax notices that only seems to make it look like the code was wrong, despite there was nothing wrong about it.

One of the most famous cases of those misleading notices was the use of the var declarations. PHP core developers wanted everybody to replace var class variable declarations with public declarations.

You may ask: what was the point of that? In my opinion, none. So why it was imposed? Because PHP 5 is a so called "more object-oriented" version of PHP. It introduced the private and protected declarations, so the old var declarations should be replaced with public to be more consistent. Be more consistent with what? Java, I suppose. But PHP is not Java.

Anyway, since the idea was really pointless and it was doing more harm than good to the PHP 5 adoption, those notices ended up being dropped.

So, is this PHP mysql extension deprecation really necessary. I don't think so, but that is just my opinion. At most it will avoid the need to maintain the documentation of multiple extensions to access MySQL databases.

So, for the PHP developers that have old code to access MySQL databases this idea will not be beneficial at all. Once the deprecation becomes official, it will start annoying PHP developers that do not want to waste time rewriting code that always worked for many years.

So I am afraid the first PHP version that introduces this deprecation will suffer from the same adoption delay problems as PHP 5.

You may argue that the ereg extension is now being deprecated in favor of the preg extension for performing operations with regular expressions. Except that it was for a good reason: the preg extension is much faster because it compiles the regular expressions and caches the compiled results, so subsequent requests that use the same regular expressions do not have to waste time parsing and compiling them again.

Your opinion

What about you? Are you in favor or against this deprecation and discontinuation of the traditional PHP MySQL extension? Do you have large chunks of code that you do not want to bother to rewrite because of this plot to kill the mysql extension? Will you still upgrade to a new PHP version that deprecates or kills this extension? Feel free to post your thoughts here.


Source - http://www.phpclasses.org/blog/post/153-The-Plot-to-Kill-PHP-MySQL-Extension.html

Link to comment
Share on other sites

Beside I still need to find all those "incredible new" features of PHP 5, they broke really a lot. With 5.3 they did the same... yet more breaking changes... for little new features.

Now to come back on the topic, MySQL functions as implemented in PHP 4 and above are not secure as you need to pass the values within the SQL query like "UPDATE toto SET a = 'myval' WHERE id=1"

This is not a good practice as the values may come from user interaction / browsers and therefore can have been changed to hijack your site (SQL Injections). MySQLi allows to pass those values in a second step which of course it increase the number of rows but at the same time ensure correct handling of string, numbers or others. No more need of mysql_real_escape or whatever. Of course for old scripts it means they will stop working, but for new code it may mean better security... may as you may still pass all in the string.

Link to comment
Share on other sites

To be honest I think dropping it is an awful idea simply because so many projects (mainly open source) still use it. Saying that I guess at least they’re giving us time to change from mysql to one of the other options.

Is it improper to use mysql for your websites and games? I only skimmed through but it seems like your saying they are going to do away with the ability to use mysql?

Well what it says is it may be classified as deprecated (the mysql_ functions/extension), and removed in a later version. This would be to get more people to use other methods.

You may want to start using the Mysqli extension rather then mysql_, but the're both using a mysql database so it's not a massive problem. The I just stands for improved.


Link to comment
Share on other sites

And that someone isme. Switching over to mysqli on your current projects will probably be a hassle. However in the creation of new projects, you might consider giving it a look see. It seems as its simply classes instead of direct.


Also i wouldnt be too concerned for this reason. Your webhost when the time comes, will probably let you choose which one you want to use, if you host yourself, you know what you want, and if you host on a free server ... Start learning one of the many more db services out there, theres over 20


Edited by runthis
Link to comment
Share on other sites

  • 1 month later...
  • 8 months later...
I'm already using PEAR's DB class, so it won't affect me.

But I do think this is gibberish, if something's not broken, don't fix it.

If people didn't fix or improve things just because it wasn't broken we would still be smashing each other over the heads with sticks.

Link to comment
Share on other sites

If people didn't fix or improve things just because it wasn't broken we would still be smashing each other over the heads with sticks.

Disregarding the fact that you dug up a year old post, let me say this.

There's a lot more the core developers of PHP can do then sit around deprecating things they believe is insecure or "bad practice".

For example, they could get around to designing a proper method of dealing with unicode characters, or even remove goto statements, which is very ineffective in a programming language such as PHP.

Edited by Spudinski
Link to comment
Share on other sites

If people didn't fix or improve things just because it wasn't broken we would still be smashing each other over the heads with sticks.

The mysql_ functions are not the same behind the scenes in PHP5 as they were when they were introduced anyway. They are improving them. This idea that they created them, and simply let them become outdated is odd.

In any case I believe the quoted comment was more geared towards the way you use the extension. He was not suggesting they don't ever change it or improve the functionality simply that there is nothing wrong with people using it. Spudinski can correct me if I have misinterpreted it... then again it was some time ago.

Link to comment
Share on other sites

  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...