php - Getting unknown empty property after joining relation in search model Yii2 -


i added

$query->joinwith('projectparticipants'); 

in search model got error:

empty property

relation correct , returns data if var_dump in view.

tried well

->leftjoin('project_participants', 'project_participants.user_id = user_cards.id') 

but same error. :(

with different relations same problem , in yii debugger queries correct.

where go wrong? empty property?

in model relation looks:

public function getprojectparticipants() {     return $this->hasmany(projectparticipants::classname(), ['user_id' => 'id']); } 

updated

public function search($params) {      $query = usercards::find();      $query->joinwith('projectparticipants');      $dataprovider = new activedataprovider([         'query' => $query,         'pagination' => array('pagesize' => 45),     ]);      $this->load($params);      if (!$this->validate()) {         // uncomment following line if not want records when validation fails         // $query->where('0=1');         return $dataprovider;     }      $query->andfilterwhere([         'project_participants.proj_id' => $this->projects,     ]);      $query->andfilterwhere(['ilike', 'name', $this->fullname ])->orfilterwhere(['like', 'surname', $this->fullname ]);       return $dataprovider; } 

the issue primary key - user_cards model generated db view no pk.

so solution add

public static function primarykey(){     return array('id'); } 

in model.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -