Beispiel #1
0
 public function __construct()
 {
     # code...
     $database = new Database();
     $db = $database->dbConnection();
     $this->conn = $db;
 }
Beispiel #2
0
 function _dbtable($tblName, $dbKey = "app")
 {
     if ($dbKey === true) {
         $dbKey = "core";
     }
     if (Database::isOpen($dbKey)) {
         return Database::dbConnection($dbKey)->get_Table($tblName);
     } else {
         return Database::connect($dbKey)->get_Table($tblName);
     }
 }
Beispiel #3
0
 private function __construct()
 {
     try {
         self::$dbConnection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
         if (!self::$dbConnection) {
             throw new Exception('Unable to connect to host');
         }
     } catch (Exception $e) {
         echo '<p> Exception was thrown: ', $e->getMessage(), '</p>';
     }
     mysql_select_db(DB_NAME, self::$dbConnection);
 }
Beispiel #4
0
 public function __construct()
 {
     $database = new Database();
     try {
         $db = $database->dbConnection();
         $this->conn = $db;
     } catch (PDOException $e) {
         //echo $e->getMessage();
         echo " DB CONNECTION ERROR ";
         return false;
     }
 }
Beispiel #5
0
 /**
  * 
  * @global array $gvDbConfig
  * @return PDO
  */
 public static function getConnection()
 {
     if (self::$dbConnection == null) {
         global $gvDbConfig;
         $dsn = "mysql:host={$gvDbConfig['host']};dbname={$gvDbConfig['database']}";
         self::$dbConnection = new PDO($dsn, $gvDbConfig['username'], $gvDbConfig['password']);
         if (self::$lockTables) {
             self::$dbConnection->exec("SET autocommit=0");
             self::$dbConnection->exec("LOCK TABLES " . implode(' WRITE, ', self::$tables) . ' WRITE');
             gfDebug('Tables are now locked');
         }
     }
     return self::$dbConnection;
 }
Beispiel #6
0
 public function __construct()
 {
     $database = new Database();
     $db = $database->dbConnection();
     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->conn = $db;
 }