我在跑步
$this->db->query("SELECT `id` FROM $table WHERE $table.id ='$product_id'");
Run Code Online (Sandbox Code Playgroud)
那应该返回92但它返回下面为什么?
object(CI_DB_mysqli_result)#150 (8) { ["conn_id"]=> object(mysqli)#16 (18) { ["affected_rows"]=> int(1) ["client_info"]=> string(6) " 5.5.30" ["client_version"]=> int(50530) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"] => string(0) "" ["field_count"]=> int(1) ["host_info"]=> string(25) "Localhost via UNIX socket" ["info"]=> NULL ["insert_id"]= > int(0) ["server_info"]=> string(10) "5.5.31-cll" ["server_version"]=> int(50531) ["stat"]=> string(150) "正常运行时间:106781 个线程: 14 题: 30097132 慢查询: 13 Opens: 1937675 Flush tables: 1 Open tables:平均每秒 400 次查询:281.858" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(373292) ["warning_count"]= > int(0) } ["result_id"]=> object(mysqli_result)#161 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"] => NULL ["num_rows"]=> int(1) ["type"]=> int(0) } ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> NULL ["row_data"]=> NULL}int(10) ["thread_id"]=> int(373292) ["warning_count"]=> int(0) } ["result_id"]=> object(mysqli_result)#161 (5) { ["current_field"]= > int(0) ["field_count"]=> int(1) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } ["result_array "]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows "]=> NULL ["row_data"]=> NULL}int(10) ["thread_id"]=> int(373292) ["warning_count"]=> int(0) } ["result_id"]=> object(mysqli_result)#161 (5) { ["current_field"]= > int(0) ["field_count"]=> int(1) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } ["result_array "]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows "]=> NULL ["row_data"]=> NULL}NULL ["num_rows"]=> int(1) ["type"]=> int(0) } ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> NULL ["row_data"]=> NULL}NULL ["num_rows"]=> int(1) ["type"]=> int(0) } ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> NULL ["row_data"]=> NULL}
它返回mysqli_ object.So设法得到的结果类似
$query = $this->db->query("SELECT `id` FROM $table WHERE $table.id ='$product_id'");
$result = $query->result();
foreach($result as $row)
{
echo "Id is ".$row['id']."<br>";
}
Run Code Online (Sandbox Code Playgroud)
值得注意的是,您使用的是 mysqli_* 函数而不是已弃用的 mysql_* 函数
| 归档时间: |
|
| 查看次数: |
12049 次 |
| 最近记录: |