Welcome Guest, Not a member yet? Register   Sign In
Practical CodeIgniter 3 - A new book coming soon
#39

@kilishan
The model class have two bugs.

find($id) and find_all() need a small fix

PHP Code:
public function find_all()
 
   {
 
       $query $this->db->get($this->table_name);

 
       $rows $this->temp_return_type == 'array' ?
 
                   $query->result_array() :
 
                   $query->result($this->temp_return_type);

 
       $this->temp_return_type $this->return_type;

 
       return $rows;
 
   


PHP Code:
public function find($id)
 
   {
 
       $query $this->db->where($this->primary_key$id)
 
                     ->get($this->table_name);

 
       $row $this->temp_return_type == 'array' ?
 
                   $query->row_array() :
 
                   $query->row(0$this->temp_return_type);

 
       $this->temp_return_type $this->return_type;

 
       return $row;
 
   

I added "db". Without the "db" the code do not return rows Smile
Reply


Messages In This Thread
RE: Practical CodeIgniter 3 - A new book coming soon - by Paradinight - 04-08-2016, 10:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB