php - Issue in building search with like query using QueryBuilder yii2 -


i trying make search query website blogs using yii2 querybuilder , there error when try execute query ->all() . here error : strtr() expects parameter 1 string, object given . , here model , controller . have no idea causing problem .

controller :

public function actionsearchblog()     {         $model = new blog();          if ($model->load(yii::$app->request->post())) {             blog::searchblog($model->search);         } else {             return $this->render('search',['model' => $model]);         }     } 

model :

public static function searchblog($search = null)     {         $search = new query();         $result = $search->select('id','title','blog','picture')           ->from('blog')           ->where(['like' , 'title' , $search])           ->orwhere(['like' , 'blog' , $search])           ->all();         echo '<pre>';         var_dump($result);         die();     } 

i tried query without ->all() @ end , var_dump value the query , won't executed . , ->all() error.

public static function searchblog($search = null) {     $query = new query();     $result = $query->select('id','title','blog','picture')       ->from('blog')       ->where(['like' , 'title' , $search])       ->orwhere(['like' , 'blog' , $search])       ->all();     echo '<pre>';     var_dump($result);     die(); } 

this work. start using ide, , watch on variables using.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -