我使用Codeigniter活動記錄一段時間了,這是我得到的最荒謬的錯誤。
我的查詢是
$this->db->select('*');
$this->db->from('my_table');
$this->db->where('is_active', 1);
$query = $this->db->get();
if ($query->num_rows() > 0) {
//return $query->result();
return $query;
} else {
return FALSE;
}
當我使用$query->result();
這是空的。當我使用return $query;
結果是類似下面,
CI_DB_pdo_result Object
(
[num_rows] => 21
[conn_id] => PDO Object
(
)
[result_id] => PDOStatement Object
(
[queryString] => SELECT * FROM my_table WHERE is_active = 1
)
[result_array] => Array
(
)
[result_object] => Array
(
)
[custom_result_object] => Array
(
)
[current_row] => 0
[row_data] =>
)
計數是
[NUM_ROWS] => 21
這到底是怎麼丟失/問題?
嘗試了所有可能的方式包括這也...不...運氣 –
$ this-> db-> select('*'); $ this-> db-> from('my_table'); $ this-> db-> where('is_active',1); return $ this-> db-> get() - > result(); 試試這個 –