Jump to content

Will mysql connection functions really disappear from PHP?


Recommended Posts

Hi,

 

The php.net pages for mysql DB connection functions say “This extension is deprecated as of PHP 5.5.0, and will be removed in the future.”

 

I thought that it would be good practice to move from mysql to mysqli so I updated my scripts.

 

Everything works fine under low load conditions (i.e. no warning or error messages, performance seems fine) but under heavy load it starts to fall apart.

 

I randomly get “Warning: mysqli::mysqli(): [2002] Only one usage of each socket address (protocol/network address/port) is normally permitted”. This seems to stop all DB interaction for the remaining execution of the script. The next script (immediately following) seems to have a random chance of encountering the same error.

 

The random nature of the problem and the fact that my scripts work fine under low load make it difficult to determine the cause.

I assume that my coding isn't the best and that mysql is in some way more fault-tolerant than mysqli.

 

The easiest solution would be for me to just return to using the mysql connection functions.

 

This made me wonder. How likely is it that the mysql connection functions would ever really be removed?

There must be millions of scripts out there that use them and and the overhead of updating them all would be enormous – I would guess comparable to the amount of work preceding the millennium.

If ISPs ever implemented a version of PHP that did not support mysql connection functions, they would be bombarded with support calls from people who operated sites using scripts that they had not themselves written and may not be able to re-write themselves.

 

So, realistically, will mysql functions ever be removed from PHP? I reckon not, but it would be interesting to hear the opinions of people better informed than I. Thanks.

So, realistically, will mysql functions ever be removed from PHP? I reckon not, but it would be interesting to hear the opinions of people better informed than I. Thanks.

 

Yes, they will.  See Request for Comments: ext/mysql deprecation for the PHP Dev's opinions on the matter.

 

Whether ISP's continue to offer a version of PHP that has them is up to them, they can do what they want.  I would guess most hosts would probably keep the option to run php 5.3/5.4/5.5 w/ t he mysql extension enabled for quite a while.  That's no excuse to keep using something that has been deprecated though.

 

If you're having issues with MySQLi then you could try using PDO and see if that works any better for you.  Otherwise try posting your code for someone to review and see if there are any issues.

 

I've only ever seen ISP to mean internet service provider, as in the company you personally pay to access the web, not the company you pay to host your site, so I don't get why you're asking about ISPs, my ISP has nothing to do with what version of PHP my hosted sites run...

 

As for your statement that: "If ISPs ever implemented a version of PHP that did not support mysql connection functions, they would be bombarded with support calls from people who operated sites using scripts that they had not themselves written and may not be able to re-write themselves."

 

Hosting companies move to newer versions of PHP, and people always complain. Just go look at our help forum to see how many people were STILL using magic quotes a decade after they should have stopped, or who suddenly had to stop using ereg_*. It's good to upgrade. If you're using a script you can't maintain or afford to hire someone who can, your site probably SHOULD go down. 

 

 

For your connection problem, it definitely sounds like something you should talk to your hosting provider about. 

I actually have a friend who is part of the PHP development mailling list and he was one of the programmers who voted for the deprecation of the mysql_* library.

I think that is really good - all mysql_* should be removed because they pose a security risk.

And I don't get why people use mysqli - PDO is way more updated and secure.

I wish there was way people would start learning making SQL queries using at least mysqli or even better PDO. Most of the beginners start with mysql_* functions and that is just plain wrong...

Edited by Stefany93
So, realistically, will mysql functions ever be removed from PHP? I reckon not, but it would be interesting to hear the opinions of people better informed than I. Thanks.

 

Yes, the mysql extension will definitely stop being bundled as part of PHP. The ball is currently rolling steadily in that direction: the community has been dissuading folks from using it for many years, the PHP manual introduced "soft-deprecation" of the mysql functions last year, and the upcoming PHP 5.5 will introduce actual deprecation. It will most likely be moved at some future point (maybe PHP 5.6) to PECL, should anyone decide they absolutely must keep on using the old extension.

Earthenware- that error is related to too many local sockets being opened up in the same port range. If this is something you're seeing normally under your traffic patterns, you might want to consider using persistent connections so that you're not constantly spinning up new sockets.

 

http://www.php.net/manual/en/mysqli.persistconns.php

Thank you for the replies.

 

I'm quite surprised, as this is sure to have a significant impact. Reading the document that kicken linked, it's interesting to see the technical arguments but it seems that only Anthony Ferrara appreciates the impact that this is going to have (at least from the quotes given).

 

My problem is now fixed so it won't affect me (thanks xylex, it was because of multiple sockets) but from a business perspective I feel very sorry for all the people out there who are going to be affected by this problem. They won't all be able to afford to hire someone to fix this for them and no, Jessica, they don't deserve to have their sites go down because of this.

They won't all be able to afford to hire someone to fix this for them and no, Jessica, they don't deserve to have their sites go down because of this.

It's not like this change is going through tomorrow. They probably won't be removed until 5.6 or maybe even 5.7, which are probably a good year or so away at least.

 

Even after they are removed, most hosts will probably still offer them via older PHP version (some hosts still over PHP4!) or custom builds that enable it. The hosts don't want to send all their customers running after all, bad for business. I'd venture to guess that the hosts will probably keep the extension around for a good three or more years.

 

Ultimately what this means is that anyone affected by this has between now and probably 2016'ish (or maybe longer even) to get their scripts updated or replaced. If they can't manage such an update with that much warning time, that is a personal failing. While they may not "deserve" to have their site go down, nobody is going to be feeling sorry for them.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.