本文整理汇总了PHP中CI_DB_pdo_driver类的典型用法代码示例。如果您正苦于以下问题:PHP CI_DB_pdo_driver类的具体用法?PHP CI_DB_pdo_driver怎么用?PHP CI_DB_pdo_driver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CI_DB_pdo_driver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* Builds the DSN if not already set.
*
* @param array
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (empty($this->dsn)) {
$this->dsn = 'informix:';
// Pre-defined DSN
if (empty($this->hostname) && empty($this->host) && empty($this->port) && empty($this->service)) {
if (isset($this->DSN)) {
$this->dsn .= 'DSN=' . $this->DSN;
} elseif (!empty($this->database)) {
$this->dsn .= 'DSN=' . $this->database;
}
return;
}
if (isset($this->host)) {
$this->dsn .= 'host=' . $this->host;
} else {
$this->dsn .= 'host=' . (empty($this->hostname) ? '127.0.0.1' : $this->hostname);
}
if (isset($this->service)) {
$this->dsn .= '; service=' . $this->service;
} elseif (!empty($this->port)) {
$this->dsn .= '; service=' . $this->port;
}
empty($this->database) or $this->dsn .= '; database=' . $this->database;
empty($this->server) or $this->dsn .= '; server=' . $this->server;
$this->dsn .= '; protocol=' . (isset($this->protocol) ? $this->protocol : 'onsoctcp') . '; EnableScrollableCursors=1';
}
}
示例2: __construct
/**
* Constructor
*
* Builds the DSN if not already set.
*
* @param array
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (empty($this->dsn)) {
$this->dsn = 'odbc:';
// Pre-defined DSN
if (empty($this->hostname) && empty($this->HOSTNAME) && empty($this->port) && empty($this->PORT)) {
if (isset($this->DSN)) {
$this->dsn .= 'DSN=' . $this->DSN;
} elseif (!empty($this->database)) {
$this->dsn .= 'DSN=' . $this->database;
}
return;
}
// If the DSN is not pre-configured - try to build an IBM DB2 connection string
$this->dsn .= 'DRIVER=' . (isset($this->DRIVER) ? '{' . $this->DRIVER . '}' : '{IBM DB2 ODBC DRIVER}') . ';';
if (isset($this->DATABASE)) {
$this->dsn .= 'DATABASE=' . $this->DATABASE . ';';
} elseif (!empty($this->database)) {
$this->dsn .= 'DATABASE=' . $this->database . ';';
}
if (isset($this->HOSTNAME)) {
$this->dsn .= 'HOSTNAME=' . $this->HOSTNAME . ';';
} else {
$this->dsn .= 'HOSTNAME=' . (empty($this->hostname) ? '127.0.0.1;' : $this->hostname . ';');
}
if (isset($this->PORT)) {
$this->dsn .= 'PORT=' . $this->port . ';';
} elseif (!empty($this->port)) {
$this->dsn .= ';PORT=' . $this->port . ';';
}
$this->dsn .= 'PROTOCOL=' . (isset($this->PROTOCOL) ? $this->PROTOCOL . ';' : 'TCPIP;');
}
}
示例3: __construct
/**
* Constructor
*
* Builds the DSN if not already set.
*
* @param array
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (empty($this->dsn)) {
$this->dsn = 'pgsql: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;
}
}
示例4: __construct
/**
* Constructor
*
* Builds the DSN if not already set.
*
* @param array
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (empty($this->dsn)) {
$this->dsn = '4D: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;
} elseif (!empty($this->char_set) && strpos($this->dsn, 'charset=', 3) === FALSE) {
$this->dsn .= ';charset=' . $this->char_set;
}
}
示例5: db_connect
/**
* Non-persistent database connection
*
* @param bool
* @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 (!is_php('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);
}
return parent::db_connect($persistent);
}
示例6: db_connect
/**
* Non-persistent database connection
*
* @param bool
* @return object
*/
public function db_connect($persistent = FALSE)
{
$this->conn_id = parent::db_connect($persistent);
if (!is_object($this->conn_id)) {
return $this->conn_id;
}
// Determine how identifiers are escaped
$query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi');
$query = $query->row_array();
$this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi'];
$this->_escape_char = $this->_quoted_identifier ? '"' : array('[', ']');
return $this->conn_id;
}
示例7: __construct
/**
* Constructor
*
* Builds the DSN if not already set.
*
* @param array
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (empty($this->dsn)) {
$this->dsn = 'firebird:';
if (!empty($this->database)) {
$this->dsn .= 'dbname=' . $this->database;
} elseif (!empty($this->hostname)) {
$this->dsn .= 'dbname=' . $this->hostname;
}
empty($this->char_set) or $this->dsn .= ';charset=' . $this->char_set;
empty($this->role) or $this->dsn .= ';role=' . $this->role;
} elseif (!empty($this->char_set) && strpos($this->dsn, 'charset=', 9) === FALSE) {
$this->dsn .= ';charset=' . $this->char_set;
}
}
示例8: __construct
/**
* Constructor
*
* Builds the DSN if not already set.
*
* @param array
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (empty($this->dsn)) {
$this->dsn = 'oci:dbname=';
// Oracle has a slightly different PDO DSN format (Easy Connect),
// which also supports pre-defined DSNs.
if (empty($this->hostname) && empty($this->port)) {
$this->dsn .= $this->database;
} else {
$this->dsn .= '//' . (empty($this->hostname) ? '127.0.0.1' : $this->hostname) . (empty($this->port) ? '' : ':' . $this->port) . '/';
empty($this->database) or $this->dsn .= $this->database;
}
empty($this->char_set) or $this->dsn .= ';charset=' . $this->char_set;
} elseif (!empty($this->char_set) && strpos($this->dsn, 'charset=', 4) === FALSE) {
$this->dsn .= ';charset=' . $this->char_set;
}
}
示例9: _delete
/**
* 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);
}
示例10: db_connect
/**
* Non-persistent database connection
*
* @param bool
* @return object
*/
public function db_connect($persistent = FALSE)
{
if (!empty($this->char_set) && preg_match('/utf[^8]*8/i', $this->char_set)) {
$this->options[PDO::SQLSRV_ENCODING_UTF8] = 1;
}
$this->conn_id = parent::db_connect($persistent);
if (!is_object($this->conn_id) or is_bool($this->_quoted_identifier)) {
return $this->conn_id;
}
// Determine how identifiers are escaped
$query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi');
$query = $query->row_array();
$this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi'];
$this->_escape_char = $this->_quoted_identifier ? '"' : array('[', ']');
return $this->conn_id;
}
示例11: db_connect
/**
* 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 (!is_php('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 ($this->stricton) {
if (empty($this->options[PDO::MYSQL_ATTR_INIT_COMMAND])) {
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode="STRICT_ALL_TABLES"';
} else {
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', @@session.sql_mode = "STRICT_ALL_TABLES"';
}
}
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) && is_php('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!';
log_message('error', $message);
return $this->db->db_debug ? $this->db->display_error($message, '', TRUE) : FALSE;
}
return $pdo;
}
示例12: _insert_batch
/**
* 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;
}
示例13: _delete
/**
* 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);
}
示例14: db_connect
/**
* Database connection
*
* @param bool $persistent
* @return object
* @todo SSL support
*/
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 (!is_php('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 ($this->stricton) {
if (empty($this->options[PDO::MYSQL_ATTR_INIT_COMMAND])) {
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode="STRICT_ALL_TABLES"';
} else {
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', @@session.sql_mode = "STRICT_ALL_TABLES"';
}
}
if ($this->compress === TRUE) {
$this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE;
}
return parent::db_connect($persistent);
}
示例15: _replace
/**
* 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);
}