简体   繁体   中英

how can i retrieve id using this method? - codeignitor db

The given syntax can insert the given values but i cannot retrieve the value with method. do anyone knoe how can i do that?

$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();

Try inserting like that

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

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

or try removing $ sign from your last line 'db'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM