bitpirate

Yii search

Feb 4th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1.         public function actionSearch( $q = NULL ) {
  2.             $query= $q;
  3.  
  4.             $account = new Account( 'search' );
  5.  
  6.             if ( Yii::app()->request->isAjaxRequest ) {
  7.  
  8.                 if ( isset( $_POST['Account'] ) ) {
  9.                     $account->attributes = $_POST['Account'];
  10.                 }
  11.  
  12.                 $accountDataProvider = $account->search();
  13.  
  14.             } else {
  15.  
  16.                 $accountDataProvider = $account->querySearch( $query);
  17.  
  18.                 if ( empty( $q ) ) {
  19.                     $accountDataProvider->setData( array() );
  20.                 }
  21.             }
  22.  
  23.             $this->render( 'search' , array(
  24.                 'accountDataProvider' => $accountDataProvider ,
  25.                 'account'             => $account ,
  26.             ) );
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment