开发者

Is the db in $this->db->last_insert() the class or the constant?

Since I am using 2 databases I have 2 separate config setups in config/database.php and load them in the Mo开发者_开发知识库del's constructor with

$this->DB1 = $this->load->database('default', TRUE);  
$this->DB2 = $this->load->database('reserve', TRUE);

I need to retrieve the id of the last inserted record and have used $this->db->last_insert(); and $this->DB2->last_insert(); but neither is working.

My insert query works fine and is

   $insArray = array(  
    'propNumber' => $prp,  
    'fname' => $fname,  
    'lname' => $lname,  
    'unit' => $unit,  
    'email' => $email,  
    'NOC' => 0  
    );  
    $this->DB2->insert('users', $insArray);  
    $last_id = $this->db->last_insert();  
    $_SESSION['userID'] = $last_id;  
    return 'valid';


http://php.net/manual/en/function.mysql-insert-id.php

$last_id = $this->DB2->mysql_insert_id();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜