CodeIgniter get_where

后端 未结 4 499
粉色の甜心
粉色の甜心 2021-01-13 22:10

I’m attempting to use get_where to grab a list of all database records where the owner is equal to the logged in user.

This is my function in my controller;

4条回答
  •  旧巷少年郎
    2021-01-13 23:01

    result() as $row): ?>
    
        name?>
    
    
    

    Remove the result function like so.

    
    
        name?>
    
    
    

    Btw. It's a much better idea to test the query for a result before you return it.

    function files()
    {
        $owner = $this->auth->get_user();
    
        $query = $this->db->get_where('files', array('owner =' => $owner))->result();
    
        if ($query->num_rows() > 0)
        {
            return $query->result();
        }
        return FALSE;
    }
    

提交回复
热议问题