/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new DriverLocation(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['DriverLocation'])) { $model->attributes = $_POST['DriverLocation']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionSetdriverlocation() { if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['lat']) || !isset($_REQUEST['long'])) { echo CJSON::encode($this->statusError('Check your parameters')); Yii::app()->end(); } $driver = Driver::model()->findByPk($_REQUEST['user_id']); if ($driver == null) { echo CJSON::encode($this->statusError('User not found')); } $driverLocation = new DriverLocation(); $driverLocation->driver_user_id = $_REQUEST['user_id']; $driverLocation->time = time(); $driverLocation->lat = $_REQUEST['lat']; $driverLocation->long = $_REQUEST['long']; if ($driverLocation->save()) { echo '1'; } }