How to return the saved() model primary key after model save()?
How to return the saved() model primary key after model save()?
Just getId() (if your primary key is called id)
<code class="php">$user = new User; $user->name='sf'; $user->save(); dump($user->id);//直接取id主键 </code>
<code>$user->save(); // 获取自增ID echo $user->id;</code>