CodeIgniter Forums

Full Version: insertID()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Getting the following exception back when using the insertID() function.

Quote:Call to undefined method CodeIgniter\Database\MySQLi\Builder::insertID()

Don't know if i'm using it the wrong way but the following line is used inside my Model.

PHP Code:
protected $table 'Clients';

public function 
__construct()
{
 
     $this->managers = \Config\Database::connect()->table($this->table);

I think, there is no insertId() in Builder. You should use $db->insertId();
(11-19-2016, 05:19 PM)ridho Wrote: [ -> ]I think, there is no insertId() in Builder. You should use $db->insertId();

Getting identical exception when setting it as you purposed.

Also please take a look at the following file:   "system\Database\MySQLi\Connection.php" on line "465" you can see it's "public function insertID() { ... }"

Got this information from the following documentation page: $db->insertID();
Try this, it's working for me

PHP Code:
protected $table 'Clients';

public function 
__construct()
{
      
$this->dbConn = \Config\Database::connect();
      
$this->managers $this->dbConn->table($this->table);

public function 
insertSomething(){
    
//your insert code
    
return $this->dbConn->insertID();