public static function getCities($stateId)
 {
     try {
         $query = "SELECT id, name FROM cities WHERE state_id=" . $stateId;
         $result = dbconfig::run($query);
         if (!$result) {
             throw new exception("City not found.");
         }
         $res = array();
         while ($resultSet = mysqli_fetch_assoc($result)) {
             $res[$resultSet['id']] = $resultSet['name'];
         }
         $data = array('status' => 'success', 'tp' => 1, 'msg' => "Cities fetched successfully.", 'result' => $res);
     } catch (Exception $e) {
         $data = array('status' => 'error', 'tp' => 0, 'msg' => $e->getMessage());
     } finally {
         return $data;
     }
 }
예제 #2
0
파일: location.php 프로젝트: bethory/Geo
 public static function getRedes()
 {
     try {
         $query = "SELECT NombreRed FROM RedesTematicas ORDER BY NombreRed ASC";
         $result = dbconfig::run($query);
         if (!$result) {
             throw new exception("r");
         }
         $res = array();
         while ($resultSet = mysqli_fetch_assoc($result)) {
             $res[] = $resultSet['NombreRed'];
         }
         $data = array('status' => 'success', 'tp' => 1, 'msg' => "redes", 'result' => $res);
     } catch (Exception $e) {
         $data = array('status' => 'error', 'tp' => 0, 'msg' => $e->getMessage());
     } finally {
         return $data;
     }
 }
예제 #3
0
 public static function getUserById($id)
 {
     try {
         $query = "SELECT * FROM users WHERE id=" . $id;
         $result = dbconfig::run($query);
         if (!$result) {
             throw new exception("Error in query");
         }
         $resultSet = mysqli_fetch_assoc($result);
         $data = array('status' => 'success', 'tp' => 1, 'msg' => "User detail fetched successfully", 'result' => $resultSet);
     } catch (Exception $e) {
         $data = array('status' => 'error', 'tp' => 0, 'msg' => $e->getMessage());
     } finally {
         return $data;
     }
 }