2017-08-14 17 views

回答

0

CodeIgniter沒有查詢相關的方法,返回數字索引結果。你可以很容易地使一個方法MY_model和轉換您的結果,或者只是這樣做:

// For results (more than one row) 
foreach($query->result_array() as $row) 
    $results[] = array_values($row); 

// For a single row 
$row = array_values($query->row_array()); 

// For the unbuffered_row 
while ($row = array_values($query->unbuffered_row('array'))) { .. etc .. 

我嘗試下面的測試,並認爲它可能是你的答案,但它只會如果你的工作使用MySQLi:

$this->load->database(); 

$query = $this->db->get('users'); 

if($query->num_rows() > 0) 
{ 
    while($row = $query->result_id->fetch_array(MYSQLI_NUM)) 
    { 
     echo '<pre>'; 
     print_r($row); 
     echo '</pre>'; 
    } 
} 
+0

這隻會爲進程添加時間。由於一些回報有數百萬行,我試圖_natively_使用整數與字段名稱。 –

+0

CodeIgniter沒有原生解決方案。自2009年以來一直使用它。它不在那裏。 –

+0

我更新了我的答案,可能適用於您,但前提是您使用的是mysqli驅動程序。 –