Reputation: 175
I'm trying to update result in the database.The Update query is working fine, values are getting updated but controller show else results always.
Below code
base Controller
#update/save in model
$data = ['twitter_link' => $this->input->post('twitter_link')];
if($this->Restaurant_admin->update_site_settings($data,'setting_id',1,'site_setting')){
$this->session->set_flashdata("update_success_twitter","Twitter link updated successfully.");
redirect('admin/Entry/basic_table');
}else{
$this->session->set_flashdata("update_success_twitter","Something went wrong data not saved.");
redirect('admin/Entry/basic_table');
}
Restaurant_admin Model
public function update_site_settings($data,$where_cond,$value,$table_name)
{
$this->db->set($data);
$this->db->where($where_cond,$value);
$this->db->update($table_name,$data);
}
#update_site_settings
Upvotes: 1
Views: 173
Reputation: 1664
In model update_site_settings
function check the query is executed or not, If executed successfully return true
else return false
public function update_site_settings($data,$where_cond,$value,$table_name)
{
$this->db->set($data);
$this->db->where($where_cond,$value);
if($this->db->update($table_name,$data))
{
return true;
}
else
{
return false;
}
}
Upvotes: 3