PHP 5.5.x中不推荐使用的MySQL扩展 [英] Deprecated MySQL extension in PHP 5.5.x

查看:95
本文介绍了PHP 5.5.x中不推荐使用的MySQL扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 PHP手册,以及从PHP 5.5开始的互联网上的大量资源. x不推荐使用整个原始MySQL扩展.我有一个非常强大的Web应用程序,我的协会中的很多学生都在使用它,但是当我不了解很多PHP时就开始使用它,而我从不担心用MySQLi_ *或PDO_MySQL更改MySQL_ *扩展

According to the PHP manual, and a lot of sources on the internet as of PHP 5.5.x the whole original MySQL extension is deprecated. I have a really robust web application that is used by a lot of students in my association, but I started working on it when I didn't know a lot of PHP and I never bothered with changing the MySQL_* extension with MySQLi_* or PDO_MySQL.

该Web应用程序已完成并且所有系统都在运行,并且可能不会通过新功能进行增强,因此我的问题是:我应该花些时间并更改所有mysql_ *调用,并使用mysqli_ *调用进行切换.如果我保留所有已弃用的mysql_ *扩展名,我的应用程序是否将无法在Internet上访问?

The web app is finished and all systems are running and will probably not be enhanced with new features, so my question is: Should I take some time and change all the mysql_* calls and switch them with mysqli_* calls. Is my application ever going to become inaccessible on the internet if I leave everything with the deprecated mysql_* extension?

推荐答案

如果我保留所有不推荐使用的mysql_ *扩展名,我的应用程序是否将无法在Internet上访问?

Is my application ever going to become inaccessible on the internet if I leave everything with the deprecated mysql_* extension?

您的应用程序只有在其运行的服务器升级到不支持旧API的PHP版本时才会中断.如果您的服务器未升级到PHP 5.5,则您的应用将无限期继续运行.在这方面,外部互联网不会影响它.仅与您自己的服务器的升级有关.

Your application will only break if and when the server it is running on is upgraded to a PHP version that doesn't support the old API. If your server doesn't get upgraded to PHP 5.5, then your app will continue running as is indefinitely. Nothing else on the outside internet will affect it in that respect; only upgrades to your own server are relevant.

目前,仍在积极支持php 5.4,因此您可以愉快地停留在该版本上,而不必担心您的代码突然中断.

For the time being, php 5.4 is still actively supported, so you can happily stay on that version without needing to worry about your code suddenly breaking.

但是,在将来的某个时候,出于某种原因,您将需要升级到PHP 5.5或更高版本. PHP 5.4将终止使用,建议升级到5.5.或者,如果您使用共享主机帐户,那么您甚至可能对PHP版本没有任何选择.因此,是的,您应该期望当前的代码不能与当时使用的PHP版本一起使用.最终.

However, at some point in the future, for one reason or another, you will need to upgrade to PHP 5.5 or higher. PHP 5.4 will become end-of-life, and a move to 5.5 will be recommended. Or if you're using a shared hosting account, you may not even have any choice over your PHP version. So yes, you should expect for your current code not to work with the PHP version you're using at the time. Eventually.

因此,尽管没有紧迫的切换需求,但您应该考虑尽快进行切换.你不想要的一件事是当事情破裂并发现自己陷入困境的那一天.

So while there's no immediate urgency to make the switch, you should consider doing so as soon as possible. One thing you don't want is for the day to come when things break, and find yourself caught out.

5.5才刚刚发布,因此您可能还需要几年的时间才能成为最低的版本,但请听我的建议.您不想等到最后一刻.

5.5 has only just been released, so you probably have a few years before it becomes the lowest version available, but take my advice; you don't want to wait till the last moment.

我应该花些时间来更改所有mysql_ *调用,并通过mysqli_ *调用进行切换.

Should I take some time and change all the mysql_* calls and switch them with mysqli_* calls.

您说您的应用程序确实很健壮",并且可能不会得到增强".因此,它基本上处于长期仅维护阶段.

You stated that your app is "really robust" and "will probably not be enhanced". So it's basically in a long-term maintenance-only phase.

鉴于这些标准,我想说的是,简单地切换到mysqli lib是明智之举.所需的更改相当琐碎(听起来您已经掌握了要做什么),并且实际上对其余软件没有任何影响.

Given those criteria, I would say that yes, making a simple switch to the mysqli lib is a sensible move. The changes required are fairly trivial (it sounds like you've got a handle on what to do already), and should have virtually no impact whatsoever on the rest of the software.

如果您的代码确实健壮且编写良好,那么您将对其进行结构化,以使数据库层具有某种形式,这意味着您无事可做.

If your code is truly robust and well-written, you'll have it structured in such that there is a database layer of some sort, which will mean that you don't have much to do anyway.

如果它的结构不是那么好,它可能在代码周围散布了许多mysql_query()调用,在这种情况下,可能需要做更多的工作.在这种情况下,由于无论如何都在处理代码,因此您可能会考虑花一些时间进行一些重组.创建一个数据库层.也许开始使用准备好的语句.我还建议切换到PDO而不是mysqli.但是您的电话-考虑到您在问题中所说的话,如果您想做尽可能少的工作,那将是可以理解的.

If it's not so well structured, it might have a lot of mysql_query() calls scattered around the code, in which case it might take a bit more work. In this case, since you're working on the code anyway, you might consider taking the time to do a bit of restructuring. Create a database layer. Maybe start using prepared statements. I'd also recommend switching to PDO rather than mysqli. But your call -- given what you said in the question, it would be understandable if you wanted to do the minimum amount of work possible.

顺便说一句-如果您尚未这样做,则可能还需要阅读以下内容:

By the way - If you haven't done so already, you might also want to read this: Why shouldn't I use mysql_* functions in PHP?

这篇关于PHP 5.5.x中不推荐使用的MySQL扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆