douhuangzhi0707 2018-09-15 01:56
浏览 64

如何删除通知错误: - 在codeigniter中最后一个插入id为null时,获取属性非对象?

I am trying to save incremented number by adding into last insert id, but when i save first value into databse table, showing the error like "notice error:-trying to get property non object". I think this error is coming because last insertid is null in table. can anyone help me to remove this error?

Thank you so much

My model:

public function last_id()
{

    $this->db->select('RA_id');
    $this->db->from('rental_agreement');
    $this->db->order_by('RA_id','DESC');
    $this->db->limit('1');
    $query = $this->db->get();
    return $query->row();

}

My controller:-

$insert_id = $this->Rental_agreement_model->last_id();
        $last_id = $insert_id->RA_id;
        if($last_id == 0){
                        $RA_num = 'RA1';
                        }
        else{
                        $RA_num = $insert_id->RA_id;
                        }
        $RA_number = $RA_num+1;
        $RA_number1 = "RA$RA_number";
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

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