예제 #1
0
 /**
  * Class constructor
  *
  * Builds the DSN if not already set.
  *
  * @param	array	$params
  * @return	void
  */
 public function __construct($params)
 {
     parent::__construct($params);
     if (empty($this->dsn)) {
         $this->dsn = 'cubrid:host=' . (empty($this->hostname) ? '127.0.0.1' : $this->hostname);
         empty($this->port) or $this->dsn .= ';port=' . $this->port;
         empty($this->database) or $this->dsn .= ';dbname=' . $this->database;
         empty($this->char_set) or $this->dsn .= ';charset=' . $this->char_set;
     }
 }
예제 #2
0
 /**
  * Delete statement
  *
  * Generates a platform-specific delete string from the supplied data
  *
  * @param	string	$table
  * @return	string
  */
 protected function _delete($table)
 {
     $this->qb_limit = FALSE;
     return parent::_delete($table);
 }
예제 #3
0
 /**
  * Insert batch statement
  *
  * Generates a platform-specific insert string from the supplied data.
  *
  * @param	string	$table	Table name
  * @param	array	$keys	INSERT keys
  * @param	array	$values	INSERT values
  * @return	string|bool
  */
 protected function _insert_batch($table, $keys, $values)
 {
     // Multiple-value inserts are only supported as of SQL Server 2008
     if (version_compare($this->version(), '10', '>=')) {
         return parent::_insert_batch($table, $keys, $values);
     }
     return $this->db->db_debug ? $this->db->display_error('db_unsupported_feature') : FALSE;
 }
예제 #4
0
 /**
  * Replace statement
  *
  * @param	string	$table	Table name
  * @param	array	$keys	INSERT keys
  * @param	array	$values	INSERT values
  * @return 	string
  */
 protected function _replace($table, $keys, $values)
 {
     return 'INSERT OR ' . parent::_replace($table, $keys, $values);
 }
예제 #5
0
 /**
  * Database connection
  *
  * @param	bool	$persistent
  * @return	object
  */
 public function db_connect($persistent = FALSE)
 {
     /* Prior to PHP 5.3.6, even if the charset was supplied in the DSN
      * on connect - it was ignored. This is a work-around for the issue.
      *
      * Reference: http://www.php.net/manual/en/ref.pdo-mysql.connection.php
      */
     if (!Core::isPHP('5.3.6') && !empty($this->char_set)) {
         $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $this->char_set . (empty($this->dbcollat) ? '' : ' COLLATE ' . $this->dbcollat);
     }
     if (isset($this->stricton)) {
         if ($this->stricton) {
             $sql = 'CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")';
         } else {
             $sql = 'REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
                                     @@sql_mode,
                                     "STRICT_ALL_TABLES,", ""),
                                     ",STRICT_ALL_TABLES", ""),
                                     "STRICT_ALL_TABLES", ""),
                                     "STRICT_TRANS_TABLES,", ""),
                                     ",STRICT_TRANS_TABLES", ""),
                                     "STRICT_TRANS_TABLES", "")';
         }
         if (!empty($sql)) {
             if (empty($this->options[PDO::MYSQL_ATTR_INIT_COMMAND])) {
                 $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode = ' . $sql;
             } else {
                 $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', @@session.sql_mode = ' . $sql;
             }
         }
     }
     if ($this->compress === TRUE) {
         $this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE;
     }
     // SSL support was added to PDO_MYSQL in PHP 5.3.7
     if (is_array($this->encrypt) && Core::isPHP('5.3.7')) {
         $ssl = array();
         empty($this->encrypt['ssl_key']) or $ssl[PDO::MYSQL_ATTR_SSL_KEY] = $this->encrypt['ssl_key'];
         empty($this->encrypt['ssl_cert']) or $ssl[PDO::MYSQL_ATTR_SSL_CERT] = $this->encrypt['ssl_cert'];
         empty($this->encrypt['ssl_ca']) or $ssl[PDO::MYSQL_ATTR_SSL_CA] = $this->encrypt['ssl_ca'];
         empty($this->encrypt['ssl_capath']) or $ssl[PDO::MYSQL_ATTR_SSL_CAPATH] = $this->encrypt['ssl_capath'];
         empty($this->encrypt['ssl_cipher']) or $ssl[PDO::MYSQL_ATTR_SSL_CIPHER] = $this->encrypt['ssl_cipher'];
         // DO NOT use array_merge() here!
         // It re-indexes numeric keys and the PDO_MYSQL_ATTR_SSL_* constants are integers.
         empty($ssl) or $this->options += $ssl;
     }
     // Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails
     if (($pdo = parent::db_connect($persistent)) !== FALSE && !empty($ssl) && version_compare($pdo->getAttribute(PDO::ATTR_CLIENT_VERSION), '5.7.3', '<=') && empty($pdo->query("SHOW STATUS LIKE 'ssl_cipher'")->fetchObject()->Value)) {
         $message = 'PDO_MYSQL was configured for an SSL connection, but got an unencrypted connection instead!';
         Logger::logError($message);
         return $this->db->db_debug ? $this->db->display_error($message, '', TRUE) : FALSE;
     }
     return $pdo;
 }
예제 #6
0
 /**
  * Delete statement
  *
  * Generates a platform-specific delete string from the supplied data
  *
  * @param	string	$table
  * @return	string
  */
 protected function _delete($table)
 {
     if ($this->qb_limit) {
         $this->where('rownum <= ', $this->qb_limit, FALSE);
         $this->qb_limit = FALSE;
     }
     return parent::_delete($table);
 }