Welcome Guest, Not a member yet? Register   Sign In
$this->db->get('users') problem
#1

[eluser]new developer[/eluser]
I have the following function. where i am retrieving all the users but get() function just returning me the top row from users table. Can any one please tell the remedy to sort this problem out.
function getAllUsers(){

$data = array();
$Q = $this->db->get('users');
if($Q->num_rows() > 0){

foreach($Q->row_array() as $row){
$data[] = $row;
}
}

$Q->free_result();
return $data;
}
#2

[eluser]Alexdamo[/eluser]
Use result_array instead of row_array

row_array returns only 1 row as an array of fields.
#3

[eluser]new developer[/eluser]
I did check it.
The result is

Array ( [0] => 1 [1] => admin [2] => sabs.67@yahoo.com [3] => active )

But i do have more users.I did try

$this->db->select('*');
$this->db->from('users');
$this->db-get();

but still the same..I think i am dumb. Can't figure out.
#4

[eluser]new developer[/eluser]
yes you are right..it did work with result_array...thanks




Theme © iAndrew 2016 - Forum software by © MyBB