Answer the question
In order to leave comments, you need to log in
Yii2 getting id before insert?
Good afternoon.
Tell me, please, is it possible to somehow get the id of the record before inserting the record into the table?
Answer the question
In order to leave comments, you need to log in
Postgre cannot be used for mysql
: stackoverflow.com/a/39509170/1603055
In yii2 to save related models use $this->id in ActiveRecord.afterSave() which will be used in child objects.
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
// $this->id уже содержит A/I ID записи
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question