Phalcon获取最后插入ID lastInsertId

<?php
    $model = new model();
    
    if($model -> create($data)) {
        $insertId = $model -> getWriteConnection() -> lastInsertId($model -> getSource());
    }
?>

是的没错,就是如此的简单!

还可以在简单一点!

<?php
    $model = new model();
    
    if($model -> create($data)) {
        $insertId = $model -> id;
    }
?>

原文:http://blog.51cto.com/ivendor/1576500

猜你喜欢

转载自blog.csdn.net/benben0729/article/details/87859758