php - yii2 hasOne relation work wrong -


i have 2 tables : users , favorite following :

users table

favorite

now establish relation between them following in favorite model

public function getuser() {     return $this->hasone(user::classname(), ['id', 'user_favorited']); } 

in controller find list of user's favorites

public function actiongetlist() {     $favorite = favorite::find()->where([               'user_favoriting' => yii::$app->user->id           ])->all();     foreach ($favorite $key => $item) {         # code...         echo "<pre>"; var_dump($item->user); echo "<br/>"; die('123');     }     return $favorite; } 

but when make request action error

column not found: 1054 unknown column '0' in 'where clause'\nthe sql being executed was: select * `users` (`0`, `1`) in ((12, 80))", 

please me!

according documentation have use:

public function getuser() {     return $this->hasone(user::classname(), ['id' => 'user_favorited']); } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -