php中mysqli替换mysql_result的官方方法

时间:2015-05-12 17:11:47   收藏:0   阅读:1003

今天升级了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];
    }
}

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

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!