Beispiel #1
0
 public function actionListarRemoto($search = null, $id = null)
 {
     $out = ['more' => false];
     if (!is_null($search)) {
         $query = new Query();
         $query->select('idvendedor AS id, nome AS text')->from('vendedor')->where('nome LIKE "%' . $search . '%"')->limit(200);
         $command = $query->createCommand();
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => Vendedor::findOne($id)->nome];
     } else {
         $out['results'] = ['id' => 0, 'text' => 'No matching records found'];
     }
     echo Json::encode($out);
 }