SHARE
TWEET

Untitled

a guest Sep 13th, 2017 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       public function actionAjaxsearch()
  2.        {
  3.         if(Yii::app()->request->isAjaxRequest && isset($_GET['term']))
  4.         {
  5.             $name = $_GET['term'];
  6.            
  7.             $criteria = new CDbCriteria;
  8.             $criteria->select = "Make, registation, serial, aircrafttypes_id"
  9.             $criteria->condition = "serial LIKE :sterm";
  10.             $criteria->params = array(":sterm"=>"%$name%");
  11.             $criteria->limit = 10;
  12.            
  13.             $aircraft = Airframes::model()->findAll($criteria);
  14.            
  15.             $retArray = array();
  16.             foreach($aircraft as $a)
  17.             {
  18. //              array_push($retArray, $a->getAttribute('Make') . " " . $a->getAttribute('registration'). " (" . $a->getAttribute('serial').")");
  19.                                 $retArray[] = $a->Make . " " . $a->registration . " " . $a->serial;
  20.             }
  21.             echo json_encode($retArray);
  22.         }  
  23.     }
RAW Paste Data
Top