Welcome Guest, Not a member yet? Register   Sign In
Best approach to implement save method of model.
#2

[eluser]sikko[/eluser]
You should avoid using $this->db->query() since codeigniter's db class has the functions to cover most of the queries.
Code:
class Brand extends CI_Model
{
    //in the constructor
    $this->table = 'brands';

    public function save($brand)
    {
        $this->db->where('id', $brand->id);
        return $this->db->update($this->table, $brand);
    }
}

Fill your object in your controller, not in your model
Code:
$brand = new stdClass();
$brand->id = $id_to_update
$brand->title = $your_pdated_title;
$brand->desc.....

if($this->brand->save($brand))
//success
else
//fail

btw, this forum is not made for code, you should try to move your thread.


Messages In This Thread
Best approach to implement save method of model. - by El Forum - 02-14-2011, 07:35 AM
Best approach to implement save method of model. - by El Forum - 02-14-2011, 08:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB