mysql_已弃用 [英] mysql_ deprecated
本文介绍了mysql_已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人告诉我mysql_
扩展名在当前版本的PHP中已被弃用,并将在某个时候将其删除.
I have been told that the mysql_
extension is now deprecated in the current version of PHP and will be removed at some point.
我应该用什么代替它?如何使用?
What should I use instead of this and how?
几乎所有查询都使用它.
For nearly all my queries I use it.
例如:
$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);
推荐答案
根据PHP
手册,您应使用以下任何一种方法:
According to the PHP
Manual, you should use any of the following:
- mysqli_stmt_num_rows()
- PDOStatement::rowCount()
但是要明确的是,这些都不是mysql_num_rows()
的简单替代.最终必须完全重写代码,以使用MySQLi或PDO API代替mysql_*()
.
To be clear though, neither of these is a mere substitute for mysql_num_rows()
. Your code must eventually be rewritten entirely to use the MySQLi or PDO API in lieu of mysql_*()
.
这篇关于mysql_已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文