コード例 #1
0
 private function __construct($db, $db_host = null, $db_user = null, $db_password = null)
 {
     self::$db = $db;
     $dsn = 'mysql:host=' . ($db_host ? $db_host : DB_HOST) . ';dbname=' . ($db ? $db : DB_NAME);
     $this->pdo = new custom_pdo_class($dsn, $db_user ? $db_user : DB_USER, $db_password ? $db_password : DB_PASSWORD);
     $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->pdo->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING);
     $this->pdo->exec("SET sql_mode = ''");
     $this->pdo->exec("SET NAMES utf8");
 }
コード例 #2
0
 private function __construct($db, $db_host = null, $db_user = null, $db_password = null, $db_host = null)
 {
     self::$db = $db;
     $dsn = 'mysql:host=' . ( $db_host ? $db_host : DB_HOST ) . ';dbname=' . ( $db ? $db : DB_NAME );
     try {
         $this->pdo = new mypdo($dsn, $db_user ? $db_user : DB_USER, $db_password ? $db_password : DB_PASSWORD);
     } catch (PDOException $e) {
         echo "Failed Connection to Database";
         exit;
     }
     $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->pdo->setAttribute(PDO::ATTR_ORACLE_NULLS ,PDO::NULL_TO_STRING);
     $this->pdo->exec("SET NAMES utf8");
 }
コード例 #3
0
ファイル: model.php プロジェクト: novichkovv/bartender
 function __construct($table, $db = null, $user = null, $password = null)
 {
     $this->pdo = db_connect_singleton::getInstance($db ? $db : DB_NAME)->pdo;
     $this->table = $table;
     $this->init();
 }