gpt4 book ai didi

php - Codeigniter 查询返回空白

转载 作者:行者123 更新时间:2023-11-29 05:08:45 26 4
gpt4 key购买 nike

我使用的是最新的 CodeIgniter 版本 (3.1.4)。我正在运行以下基本查询:

$query = $this->db->query("SELECT * FROM mytable;");

得到一个空白结果——num_rows 和 row_data 都是空白的。这是 $query 的 print_r 输出:

CI_DB_mysqli_result Object
(
[conn_id] => mysqli Object
(
[affected_rows] => 2
[client_info] => mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
[client_version] => 50012
[connect_errno] => 0
[connect_error] =>
[errno] => 0
[error] =>
[error_list] => Array
(
)

[field_count] => 7
[host_info] => Localhost via UNIX socket
[info] =>
[insert_id] => 0
[server_info] => 5.6.35
[server_version] => 50635
[stat] => Uptime: 2988249 Threads: 2 Questions: 13445030 Slow queries: 9 Opens: 784 Flush tables: 1 Open tables: 469 Queries per second avg: 4.499
[sqlstate] => 00000
[protocol_version] => 10
[thread_id] => 922470
[warning_count] => 0
)

[result_id] => mysqli_result Object
(
[current_field] => 0
[field_count] => 7
[lengths] =>
[num_rows] => 2
[type] => 0
)

[result_array] => Array
(
)

[result_object] => Array
(
)

[custom_result_object] => Array
(
)

[current_row] => 0
[num_rows] =>
[row_data] =>
)

谁能帮我弄清楚这里出了什么问题?

最佳答案

这些值将保持空白,直到您调用生成结果的方法之一 - documented here .

试试这个

$query = $this->db->query("SELECT * FROM mytable;");
echo "Rows: ". $query->num_rows(). "<br>";
$data = $query->result();
var_dump($data);

看到什么了吗?

关于php - Codeigniter 查询返回空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43194706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com