How to detect the last insert ID within a transaction in Yii using DAO?

后端 未结 3 1144
迷失自我
迷失自我 2021-01-12 04:59

That\'s the source code, I need to detect the ID (see the marked position between the two queries below).

$connection = Yii::app()->db;
$transaction=$conn         


        
3条回答
  •  萌比男神i
    2021-01-12 05:14

    you can try both way,here getLastInsertID is method and lastInsertID is property

    $lastInsertID = $connection->getLastInsertID();
    

    or

    $lastInsertID = $connection->lastInsertID;
    

    for more info http://www.yiiframework.com/doc/api/1.1/CDbConnection

提交回复
热议问题