duanaigua4033 2017-07-13 09:56
浏览 14
已采纳

controller / model不会返回true结果

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
  • 写回答

1条回答 默认 最新

  • dpgu5074 2017-07-13 10:02
    关注

    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;
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数