I have to perform the edit/update operation through the same page from which I am performing the insert operation. I get error undefined $select
.
This is my method :
function editCategory($catId,$datavalue)
{
$data=array(
'CategoryName' => $datavalue['CategoryName'],
'Status' => $datavalue['Status']
);
$this->db->update('tblcategory');
$this->db->set($data);
$this->db->where('id',$catId)
$this->db->select('*');
$this->db->from('tblcategory');
$this->db->where('id',$catId);
$query=$this->db->get()->row();
//$result=$query->row_array();
if($query)
{
return $query;
}
else
{
return false;
}
}
Hope this will help you :
Make the correct clause order at update
query means where
and set
clause should come first , should be like this :
Note : make sure $catId
and $datavalue
are not empty pls add check for them
function editCategory($catId, $datavalue)
{
$data = array(
'CategoryName' => $datavalue['CategoryName'],
'Status' => $datavalue['Status']
);
$this->db->set($data);
$this->db->where('id',$catId);
$this->db->update('tblcategory');
$this->db->select('*');
$this->db->from('tblcategory');
$this->db->where('id',$catId);
$query=$this->db->get()->row();
if($query)
{
return $query;
}
else
{
return false;
}
}
For more :https://www.codeigniter.com/user_guide/database/query_builder.html