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

Viewed 29

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();
1 Answers

Try inserting like that

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

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

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

Related