sql - Code igniter return index keys vs. associative on unbuffered_row -
i have following line of code in project:
while ($row = $query->unbuffered_row('array')) { .. etc ..
logging values of $row
associative - , db column names quite long.
how return $row
indexed 0 n, vs. associatively? know column names. thanks
codeigniter has no query related method returns numeric indexed results. make method in my_model , convert results, or this:
// results (more 1 row) foreach( $query->result_array() $row ) $results[] = array_values( $row ); // single row $row = array_values( $query->row_array() ); // unbuffered_row while ($row = array_values($query->unbuffered_row('array'))) { .. etc ..
i tried following test, , believe may answer, work if you're using 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>'; } }
Comments
Post a Comment