Exemplo n.º 1
0
 public function createDefault($id = 0)
 {
     // creates default UserLocation entry for a user if not exists
     $x = UserLocation::model()->findByAttributes(array('user_id' => $id));
     if ($x === null) {
         $ul = new UserLocation();
         $ul->neighborhood_id = 0;
         // default
         $ul->user_id = $id;
         $ul->gps = new CDbExpression("GeomFromText('Point(0 0)')");
         // default
         $ul->address = '';
         $ul->address_ext = '';
         $ul->save();
     }
 }
 /**
  * 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 = UserLocation::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 3
0
 public function loadModelByUser($id)
 {
     $model = UserLocation::model()->findByAttributes(array('user_id' => $id));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }