• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
insertID()

#1
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);

Reply

#2
I think, there is no insertId() in Builder. You should use $db->insertId();
Need a free blog? try Mitha Blog. Here You can create a free website or build a blog with dozens of free, customizable, mobile-ready designs and themes.
Reply

#3
(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();
Reply

#4
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();

Need a free blog? try Mitha Blog. Here You can create a free website or build a blog with dozens of free, customizable, mobile-ready designs and themes.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.