mysql_result() 有替代方法吗

PHPz
Release: 2020-09-05 11:07:40
Original
2512 people have browsed it

“mysql_result()”是有替代方法的,可以使用mysqli来替换“mysql_result”,使用语句如“mysqli_data_seek($result, $number);”。

mysql_result() 有替代方法吗

mysql_result()有替代方法,可以使用mysqli来替换mysql_result;因为官方自php5.3开始一直推荐mysqli和pdo。

php中mysqli替换mysql_result的官方方法

今天升级了php版本,顺便想把php代码中的mysql连接方式改成mysqli,因为官方自php5.3开始一直推荐mysqli 和 pdo 。不多说了,贴代码

// here's a rough replacement using mysqli:
// 错略的使用mysqli替换
if (!function_exists('mysql_result')) {
    function mysql_result($result, $number, $field=0) {
        mysqli_data_seek($result, $number);
        $row = mysqli_fetch_array($result);
        return $row[$field];
    }
}
Copy after login

php官方网址:http://php.net/manual/zh/function.mysql-result.php

相关参考:php中文网

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template