开发者

no idea why my model returns two different values

开发者 https://www.devze.com 2023-01-10 05:28 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号