public function actionCeksuplier() { if (strpos($_GET['term'], "(") === false) { $condition = $_GET['term']; $criteria = new CDbCriteria(); $criteria->condition = " suplier_name like '%{$condition}%'"; $criteria->limit = 7; $info = Suplier::model()->findAll($criteria); $arModels = array(); foreach ($info as $model) { $dataprice = ComponentSuplier::model()->findByAttributes(array('suplier_id' => $model->id, 'component_id' => intval($_GET['component_id']))); $price = $dataprice == null ? 0 : $dataprice->price; $arModels[] = array('id' => $model->id, 'address' => $model->address, 'price' => $price, 'label' => $model->suplier_name, 'value' => $model->suplier_name); } echo CJSON::encode($arModels); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = ComponentSuplier::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }