开发者

mysql and php news breakdown

I have just read about http://marc.info/?l=php-internals&m=131031747409271&w=2.

I use mysql_query in all my php code for the last year to access my mysql databases.

Does the information at that link, from the PHP leader, mean I can no longer use mysql_query?

Will mysql_query stop working in the future? If so, when will this happen? What is the new way to access a mysql database w开发者_运维技巧ith php?

Would someone mind simplifying what the link is saying in simply english?

I am worried, thank you.

Extra: What does deprecated actually mean, it is not a common word for non technical people...? instead of mysql_query, what do I use? Do I write mysqli_query? or PDO_query? what is the difference between mysql and mysqli and pdo queries? Do I need to use mysqli or pdo software instead of mysql databases?


For years now, it's been recommended to use The MySQLi or PDO extensions -- and not the old MySQL one.


As a reference, see this page of the PHP manual : Overview of APIs (quoting) :

What is PHP's MySQL Extension?

This is the original extension designed to allow you to develop PHP applications that interact with a MySQL database. The mysql extension provides a procedural interface and is intended for use only with MySQL versions older than 4.1.3. This extension can be used with versions of MySQL 4.1.3 or newer, but not all of the latest MySQL server features will be available.
If you are using MySQL versions 4.1.3 or later it is strongly recommended that you use the mysqli extension instead.


The link you posted states that mysql_* functions are not going to disappear soon, so don't panick (quoting) :

Don't panic! This is not a proposal to add errors or remove this popular extension.
Not yet anyway, because it's too popular to do that now.


But the idea is that mysql_* functions should not be used anymore (as it's been the case for years already) -- but people are still using these, instead of PDO or MySQLi.

An idea / proposition to help people realize that there are better solutions than mysql_* would be to mark those old functions as deprecated -- in a future version of the language.

It will probably not happen for PHP 5.4 (which is already in alpha stage) ; maybe for PHP 5.5 -- but that one is far from released -- probably at least two years...


Right now, for your new projects, you should probably not use mysql_* ; instead, you should use MySQLi or PDO, which are more recent, and support more features of the MySQL server.

But for your old code, it's probably OK to keep using the mysql_* functions -- at least for a while: no need to re-write your existing applications.



What does deprecated actually mean, it is not a common word for non technical people...?

It means that, when those functions are deprecated and you try calling them, you will get a warning saying you are using old functions, that should not be used anymore -- and that will disappear one day or another.


instead of mysql_query, what do I use? Do I write mysqli_query? or PDO_query?

Read the documentation of MySQLi and PDO ;-)


what is the difference between mysql and mysqli and pdo queries?

Those are two extensions :

  • MySQLi is the improved extension, to communicate with a MySQL Server
  • PDO is an extension that allows to communicate with several SQL Servers (Oracle, SQLIte, MySQL, ...) with the same PHP classes.


Do I need to use mysqli or pdo software instead of mysql databases?

On the Server-side, you will still use the same MySQL Server.
On the client-side, you choose the extension you want.


mysql_query is going to be deprecated, but not within the next year or two. This extension has been advocated against for a long time, and the first steps toward eventual deprecation are finally taking place. I wouldn't worry too much about it -- you're in complete control -- for now.

Conversion to mysqli would be easiest, but PDO is preferable.


From the mail list:

Don't panic! This is not a proposal to add errors or remove this popular extension. \ Not yet anyway, because it's too popular to do that now.

All that post is talking about is trying to make users aware of "better" alternatives in the docs and deprecating it in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜