mysql - 在 mysqli 中转换 mysql_result

标签 mysql

我正在尝试将 mysql_result 转换为 mysqli。没有同等的转换。

$total_items = mysql_result(mysql_query($con,' SELECT FOUND_ROWS(); '), 0, 0);    
$this->items = $data;

最佳答案

已弃用的mysql_result等于新的mysqli命令mysqli_fetch_field。您可以在 php.net 文档中找到示例。例如非面向对象:

<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";

if ($result = mysqli_query($link, $query)) {

    /* Get field information for all fields */
    while ($finfo = mysqli_fetch_field($result)) {

        printf("Name:     %s\n", $finfo->name);
        printf("Table:    %s\n", $finfo->table);
        printf("max. Len: %d\n", $finfo->max_length);
        printf("Flags:    %d\n", $finfo->flags);
        printf("Type:     %d\n\n", $finfo->type);
    }
    mysqli_free_result($result);
}

/* close connection */
mysqli_close($link);
?>

mysqli_fetch_field

关于mysql - 在 mysqli 中转换 mysql_result,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34521268/

相关文章:

php - 使用单个查询和每个用户密码 salt 的用户登录

mysql - 为有限数量的选项验证字符串输入的最佳方法

mysql - 如何知道 MySQL 何时达到服务器的内存限制?

MySQL多对多连接,即使没有关系

php - 无法将 MySQL 表转储分解为与表行对应的新行

mysql - 从不同表中的 2 列中获取总和

php - 根据最新的关联对象查询

mysql - 学说 2 密切联系

php - 如何在MYSQL中存储用户购买?

php - Symfony2 - 显示数据库中的所有表