Created
December 31, 2014 04:32
-
-
Save Khan143/4dead461868b06725b0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function actionSearch($q=''){ | |
| $q = addcslashes($q, '%_'); | |
| $criteria1 = new CDbCriteria; | |
| $criteria1->addCondition("first_name LIKE :first_name", 'OR'); | |
| $criteria1->addCondition('last_name LIKE :last_name', 'OR'); | |
| $criteria1->params = array(':first_name'=>"%$q%", ':last_name'=>"%$q%"); | |
| $members = Members::model()->findAll($criteria1); | |
| $rawData = array(); | |
| foreach($members as $member){ | |
| $row = array(); | |
| // $row['id'] = $members->id; | |
| $row['first_name'] = $member->first_name; | |
| $row['last_name'] = $member->last_name; | |
| $row['user_name'] = $member->user_name; | |
| $row['address'] = $member->address; | |
| $rawData[] = $row; | |
| } | |
| $criteria = new CDbCriteria; | |
| $criteria->addCondition("title LIKE :title", 'OR'); | |
| $criteria->addCondition('content LIKE :content', 'OR'); | |
| $criteria->params = array(':title'=>"%$q%", ':content'=>"%$q%"); | |
| $posts = Posts::model()->findAll($criteria); | |
| foreach($posts as $post){ | |
| $row = array(); | |
| // $row['id'] = $posts->id; | |
| $row['title'] = $post->title; | |
| $row['content'] = $post->content; | |
| $rawData[] = $row; | |
| } | |
| $dataProvider = new CArrayDataProvider($rawData, array( | |
| // 'keyField' => 'id', | |
| 'pagination'=>array( | |
| 'pageSize'=>20, | |
| ), | |
| // 'criteria' => $criteria, | |
| )); | |
| $this->render('search', array( | |
| 'dataProvider' => $dataProvider, | |
| )); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment