Extracting array? |
[eluser]solid9[/eluser]
I have these codes below, <b>controller: main.php </b> Code: function show_r() { <b>model: bs_model.php </b> code] function get_createdon($to) { $query = $this->db->select('username, created_on') ->from('users') ->where('email', $to) ->get(); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } return $data; } else { return FALSE; } } [/code] The controller above is not working properly I'm trying to extract the data from the model. But it did not work, the error message is below, Code: A PHP Error was encountered Thanks in advanced
[eluser]PhilTem[/eluser]
$data_array most likely contains many objects, therefore you either have to foreach-loop over them, or do Code: return $query->row(); And don't forget, Code: print_r() as well as Code: var_dump() are your best friends
[eluser]aquary[/eluser]
Also, you forgot to check tf the returned data is really a data, not a FALSE or empty array. |
Welcome Guest, Not a member yet? Register Sign In |