Jump to content


Photo

Will mysql connection functions really disappear from PHP?


Best Answer salathe, 23 February 2013 - 12:29 PM

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. Go to the full post


  • Please log in to reply
7 replies to this topic

#1 Earthenware

Earthenware

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 23 February 2013 - 10:25 AM

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.

#2 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,731 posts
  • LocationBonita, FL

Posted 23 February 2013 - 11:41 AM

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.

Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#3 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 23 February 2013 - 11:47 AM

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. 
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#4 Stefany93

Stefany93

    Advanced Member

  • Members
  • PipPipPip
  • 176 posts
  • Age:20

Posted 23 February 2013 - 12:20 PM

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, 23 February 2013 - 12:21 PM.

"Put your faith in God and keep your powder dry" - Oliver Cromwell
My site - http://dyulgerova.info

My history website - http://www.studyingthepast.com


#5 salathe

salathe

    Badger

  • Staff Alumni
  • 1,859 posts
  • LocationEdinburgh, Scotland

Posted 23 February 2013 - 12:29 PM   Best Answer

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.
PHP Documentation Team

#6 xylex

xylex

    Advanced Member

  • Members
  • PipPipPip
  • 292 posts

Posted 25 February 2013 - 01:01 AM

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/m...ersistconns.php
The greatest inefficiencies come from solving problems you will never have.  -Rasmus

PHP Development Blog

#7 Earthenware

Earthenware

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 27 February 2013 - 03:02 AM

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.



#8 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,731 posts
  • LocationBonita, FL

Posted 27 February 2013 - 04:14 AM

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.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com