コード例 #1
0
 /**
  * Zwrocenie polaczenia
  *
  * @return polaczenie
  */
 public static function getConnection()
 {
     $conn = mysql_connect(ConnectionProperty::getHost(), ConnectionProperty::getUser(), ConnectionProperty::getPassword());
     mysql_select_db(ConnectionProperty::getDatabase());
     if (!$conn) {
         throw new Exception('could not connect to database');
     }
     return $conn;
 }
コード例 #2
0
ファイル: Connection.class.php プロジェクト: Entrax643/School
 /**
  * Wykonanie zapytania sql na biezacym polaczeniu
  *
  * @param sql zapytanie sql
  * @return wynik zapytania
  */
 public function executeQuery($sql)
 {
     $conn = mysqli_connect(ConnectionProperty::getHost(), ConnectionProperty::getUser(), ConnectionProperty::getPassword());
     //mysqli_select_db(ConnectionProperty::getDatabase());
     mysqli_select_db($conn, "fredi");
     if (!$conn) {
         throw new Exception('could not connect to database');
     }
     return mysqli_query($this->connection, $sql);
 }
コード例 #3
0
 /**
  * Zwrocenie polaczenia
  *
  * @return polaczenie
  */
 public static function getConnection()
 {
     $conn = mysqli_connect(ConnectionProperty::getHost(), ConnectionProperty::getUser(), ConnectionProperty::getPassword());
     mysqli_select_db($conn, ConnectionProperty::getDatabase());
     if (!$conn) {
         throw new Exception('could not connect to database');
     }
     mysqli_query($conn, "SET NAMES UTF8");
     return $conn;
 }
コード例 #4
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         try {
             self::$instance = new PDO('mysql:host=' . ConnectionProperty::getHost() . ';dbname=' . ConnectionProperty::getDatabase() . ';charset=utf8', ConnectionProperty::getUser(), ConnectionProperty::getPassword());
             self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             self::$instance->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
         } catch (PDOException $e) {
             echo $e->getMessage();
         }
     }
     return self::$instance;
 }
コード例 #5
0
 public static function getConnection()
 {
     $db = null;
     if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false) {
         // Connect from App Engine.
         $db = mysql_connect(':/cloudsql/vod-ventana-educativa:vod', 'root', '');
     } else {
         // Connect from a development environment.
         $db = mysql_connect(ConnectionProperty::getHost(), ConnectionProperty::getUser(), ConnectionProperty::getPassword());
     }
     mysql_set_charset('utf8', $db);
     mysql_select_db(ConnectionProperty::getDatabase());
     if (!$db) {
         die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
     }
     return $db;
 }