0

My controller:

function search()
    {
        $this->load->model('membership_model');
        $this->membership_model->search();

    }

Model:

function search()
    {
    $q = $this->db->get('feeds');
    var_dump($q);
    }

Why var_dump it returns me this:

object(CI_DB_mysql_result)#19 (8) { ["conn_id"]=> resource(57) of type (mysql link persistent) ["result_id"]=> resource(68) of type (mysql result) ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(325) ["row_data"]=> NULL } 

It is normal? it not supposed to display me another format of data? Array...etc[]=>[]

user3313651
  • 105
  • 1
  • 1
  • 8

2 Answers2

1

to display the data you should write:

var_dump($q->result());

because:

$this->db->get();

returns an object from class CI_DB_mysql_result. which has the following fields in it:

$conn_id, $result_id, $result_array,
 $result_object, $custom_result_object, $current_row, $num_rows, $row_data

which you are seeing in your var_dump

mamdouh alramadan
  • 8,349
  • 6
  • 36
  • 53
0

You need to convert the query result into an array of items or object of items

var_dump($q->result());

or

var_dump($q->result_array());

Using array is less memory consuming

Kalzem
  • 7,320
  • 6
  • 54
  • 79