1

I am using Yii 2.0 framework , Can anyone help me to write insert query in the controller please, I am writing query like this, is this a proper query

$userId = \Yii::$app->user->identity->id;
    $restId = \app\models\Restaurantbusiness::find()->select('restaurentID')->where(['userId' => $userId ])->one(); 
    $restdetailId = $restId->restaurentID;
    $restomenuID = Restomenu::find()->insert('restaurantBusiness_restaurentID')->where(['restaurantBusiness_restaurentID' => $restdetailId])->One();

please help me to write the correct insert query. Thanks in advance

1 Answer 1

1

ok i assume no one knows :-/

i found the solution

there is no need to write any insert query at all, in controller before saving i wrote this

$model->restaurantBusiness_restaurentID= $restdetailId;

thats all.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.