This is my view all function in my postcards model, in one controller it returns 4 and the other returns, no idea why, I'm echoing num_rows() to see whats going on.
Theres nothing else being passed, its exactly the same except, one view is a front for a facebook and one view is an admin secti开发者_Go百科on
function view_all(){
$query = $this->db->get('postcards');
echo $query->num_rows();
$data = Array();
if ($query->num_rows() > 0){
foreach($query->result_array() as $row){
$data[] = $row;
}
}
$query->free_result();
return $data;
}
Maybe try changing it around a little bit to help you out:
function view_all(){
$query = $this->db->get('postcards');
echo $query->num_rows();
// $data = Array();
if ($query->num_rows() > 0){
foreach($query->result_array() as $row){
$data[] = $row;
}
return $data;
}
$query->free_result();
}
Let me know what happens now.
精彩评论