<?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; } ?>