2015-12-30 95 views
0

我試圖將mysql_result轉換成mysqli。它沒有相同的轉換。將mysql_result轉換爲msqli

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

回答

1

棄用的mysql_result等於新的mysqli命令mysqli_fetch_field。你可以在php.net文檔中找到exampled。例如非面向對象:

<?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