Hello
I need to get id in moment that I save data. For example, I save my datas using this way:
//simple example to save
$myModel = new MyBodel();
$myModel->attributes=$_POST["MyModel"];
if($myModel->save()){
$find_last_data = MyModel::find()->orderBy(['id'=> SORT_DESC])->limit(1)->one();
$id = $find_last_data["id"];
}
else
echo "erro";
But is it the better way? There is the possibility of when I use this line:
$find_last_data = MyModel::find()->orderBy([‘id’=> SORT_DESC])->limit(1)->one();
Other register is inserted in my table and I get wrong id? Many people use my app in same time.