Beispiel #1
0
 function __construct($page, $size)
 {
     include 'dbconfig.php';
     $dbObject = new dbconfig();
     $this->dbCred = $dbObject->getConnDetails();
     mysql_connect($this->dbCred['host'], $this->dbCred['username'], $this->dbCred['password']);
     mysql_select_db($this->dbCred['database']);
     $this->page = $page;
     $this->size = $size;
 }
Beispiel #2
0
 public static function driver($driver)
 {
     $config = dbconfig::get();
     list($driver_type, $desc) = explode('.', $driver);
     $driver_type .= self::DRIVER_TAIL;
     if (isset(self::$drivers[$driver])) {
         return self::$drivers[$driver];
     }
     if (class_exists($driver_type)) {
         return self::$drivers[$driver] = new $driver_type($config);
     } else {
         die('driver not found' . PHP_EOL);
     }
 }
 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;
     }
 }
Beispiel #4
0
 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;
     }
 }
 function __construct()
 {
     include_once 'dbconfig.php';
     $dbObject = new dbconfig();
     $this->dbCred = $dbObject->getConnDetails();
 }
Beispiel #6
0
 function __construct()
 {
     self::$con = self::connect();
 }
Beispiel #7
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;
     }
 }