【问题标题】:how can i retrieve id using this method? - codeignitor db如何使用此方法检索 id? - 代码点火器数据库
【发布时间】:2021-06-11 06:06:20
【问题描述】:

给定的语法可以插入给定的值,但我无法使用方法检索值。有人知道我该怎么做吗?

$supplier = array(
            'cname' => $request->getPost('cname'),            
            'clname'  => $request->getPost('clname'),
            'tlidt'  => $request->getPost('tlidt'),
            'tledt'  => $request->getPost('tledt'),
            'pname'  => $request->getPost('pname'),
            'tla'  => $request->getPost('tla'),
        );
        $builder = $db->table('suppliers');
        $builder->insert($supplier);
        $id = $this->$db->insert_id();

【问题讨论】:

    标签: php codeigniter-4


    【解决方案1】:

    尝试这样插入

    $this->db->insert('suppliers',$supplier);

    $id = $this->db->insert_id();

    或尝试从最后一行 'db' 中删除 $ 符号。

    【讨论】:

      猜你喜欢
      • 2013-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多