本文整理汇总了PHP中CI_DB类的典型用法代码示例。如果您正苦于以下问题:PHP CI_DB类的具体用法?PHP CI_DB怎么用?PHP CI_DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CI_DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CI_DB_oci10_driver
function CI_DB_oci10_driver($params)
{
$this->clean();
if (defined('SQLT_RSET')) {
$this->_iCursorType = SQLT_RSET;
} else {
$this->_iCursorType = OCI_B_CURSOR;
}
if (defined('SQLT_NTY')) {
$this->_iCollectionType = SQLT_NTY;
} else {
$this->_iCollectionType = OCI_B_NTY;
}
if (defined('SQLT_CHR')) {
$this->_iDefaultType = SQLT_CHR;
} else {
$this->_iDefaultType = 1;
}
parent::CI_DB_driver($params);
}
示例2: CI_DB_odbc_driver
function CI_DB_odbc_driver($params)
{
parent::CI_DB($params);
$this->_random_keyword = ' RND(' . time() . ')';
// database specific random keyword
}
示例3: CI_DB_sqlrelay_driver
/**
* Constructor
*
*/
function CI_DB_sqlrelay_driver($params)
{
// function __construct() {
$this->clean();
$this->setIsOracle(false);
$this->_iPrefetch = 1000;
if (isset($params['getNullsAsNulls']) && true === $params['getNullsAsNulls']) {
$this->_bgetNullsAsNulls = true;
}
parent::CI_DB_driver($params);
//$this->setAutoCommitOn();
}
示例4: __construct
public function __construct($params)
{
parent::__construct($params);
if (!empty($this->port)) {
$this->hostname .= (DIRECTORY_SEPARATOR === '\\' ? ',' : ':') . $this->port;
}
}
示例5: elseif
function __construct($params)
{
parent::__construct($params);
// clause and character used for LIKE escape sequences
if (strpos($this->hostname, 'mysql') !== FALSE) {
$this->_like_escape_str = '';
$this->_like_escape_chr = '';
//Prior to this version, the charset can't be set in the dsn
if (is_php('5.3.6')) {
$this->hostname .= ";charset={$this->char_set}";
}
//Set the charset with the connection options
$this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
} elseif (strpos($this->hostname, 'odbc') !== FALSE) {
$this->_like_escape_str = " {escape '%s'} ";
$this->_like_escape_chr = '!';
} else {
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
/**
* @link http://stackoverflow.com/questions/11054618/codeigniter-pdo-database-driver-not-working
*/
// empty($this->database) OR $this->hostname .= ';dbname='.$this->database;
$this->hostname = 'mysql:dbname=' . $this->database . ';host=' . $this->hostname;
$this->trans_enabled = FALSE;
$this->_random_keyword = ' RND(' . time() . ')';
// database specific random keyword
}
示例6: end
function __construct($params)
{
parent::__construct($params);
if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) == 2) {
// If there is a minimum valid dsn string pattern found, we're done
// This is for general PDO users, who tend to have a full DSN string.
$this->pdodriver = end($match);
} else {
// Try to build a complete DSN string from params
$this->_connect_string($params);
}
// clause and character used for LIKE escape sequences
// this one depends on the driver being used
if ($this->pdodriver == 'mysql') {
$this->_like_escape_str = '';
$this->_like_escape_chr = '';
} elseif ($this->pdodriver == 'odbc') {
$this->_like_escape_str = " {escape '%s'} ";
$this->_like_escape_chr = '!';
} else {
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
$this->trans_enabled = FALSE;
$this->_random_keyword = ' RND(' . time() . ')';
// database specific random keyword
}
示例7: elseif
function __construct($params)
{
parent::__construct($params);
// clause and character used for LIKE escape sequences
if (strpos($this->hostname, 'mysql') !== FALSE) {
$this->_like_escape_str = '';
$this->_like_escape_chr = '';
//Prior to this version, the charset can't be set in the dsn
if (is_php('5.3.6')) {
$this->hostname .= ";charset={$this->char_set}";
}
//Set the charset with the connection options
$this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
} elseif (strpos($this->hostname, 'odbc') !== FALSE) {
$this->_like_escape_str = " {escape '%s'} ";
$this->_like_escape_chr = '!';
} else {
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
empty($this->database) or $this->hostname .= ';dbname=' . $this->database;
$this->trans_enabled = FALSE;
$this->_random_keyword = ' RND(' . time() . ')';
// database specific random keyword
}
示例8: __construct
/**
* Class constructor
*
* @param array $params
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (!empty($this->port)) {
$this->hostname .= ':' . $this->port;
}
}
示例9: __construct
public function __construct($params)
{
parent::__construct($params);
$this->_random_keyword = ' RND(' . time() . ')';
// database specific random keyword
// Legacy support for DSN in the hostname field
if (empty($this->dsn)) {
$this->dsn = $this->hostname;
}
}
示例10: SelectWhere
function SelectWhere($table, $wherefield, $wherevalue) {
$this->db->where($wherefield, $wherevalue);
$query = $this->db->get($table);
$results = array();
foreach ($query->result() as $row)
{
$results[] = (array)$row;
}
return $results;
}
示例11: __construct
/**
* Class constructor
*
* @param array $params
* @return void
*/
public function __construct($params)
{
parent::__construct($params);
if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\\?.+)?$/', $this->dsn, $matches)) {
if (stripos($matches[2], 'autocommit=off') !== FALSE) {
$this->auto_commit = FALSE;
}
} else {
// If no port is defined by the user, use the default value
empty($this->port) or $this->port = 33000;
}
}
示例12: __construct
public function __construct($params)
{
parent::__construct($params);
$valid_dsns = array('tns' => '/^\\(DESCRIPTION=(\\(.+\\)){2,}\\)$/', 'ec' => '/^(\\/\\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\\/[a-z0-9$_]+)?(:[^\\/])?(\\/[a-z0-9$_]+)?$/i', 'in' => '/^[a-z0-9$_]+$/i');
/* Space characters don't have any effect when actually
* connecting, but can be a hassle while validating the DSN.
*/
$this->dsn = str_replace(array("\n", "\r", "\t", ' '), '', $this->dsn);
if ($this->dsn !== '') {
foreach ($valid_dsns as $regexp) {
if (preg_match($regexp, $this->dsn)) {
return;
}
}
}
// Legacy support for TNS in the hostname configuration field
$this->hostname = str_replace(array("\n", "\r", "\t", ' '), '', $this->hostname);
if (preg_match($valid_dsns['tns'], $this->hostname)) {
$this->dsn = $this->hostname;
return;
} elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE && (!empty($this->port) && ctype_digit($this->port) or $this->database !== '')) {
/* If the hostname field isn't empty, doesn't contain
* ':' and/or '/' and if port and/or database aren't
* empty, then the hostname field is most likely indeed
* just a hostname. Therefore we'll try and build an
* Easy Connect string from these 3 settings, assuming
* that the database field is a service name.
*/
$this->dsn = $this->hostname . (!empty($this->port) && ctype_digit($this->port) ? ':' . $this->port : '') . ($this->database !== '' ? '/' . ltrim($this->database, '/') : '');
if (preg_match($valid_dsns['ec'], $this->dsn)) {
return;
}
}
/* At this point, we can only try and validate the hostname and
* database fields separately as DSNs.
*/
if (preg_match($valid_dsns['ec'], $this->hostname) or preg_match($valid_dsns['in'], $this->hostname)) {
$this->dsn = $this->hostname;
return;
}
$this->database = str_replace(array("\n", "\r", "\t", ' '), '', $this->database);
foreach ($valid_dsns as $regexp) {
if (preg_match($regexp, $this->database)) {
return;
}
}
/* Well - OK, an empty string should work as well.
* PHP will try to use environment variables to
* determine which Oracle instance to connect to.
*/
$this->dsn = '';
}
示例13: RND
function __construct($params)
{
parent::__construct($params);
// clause and character used for LIKE escape sequences
if (strpos($this->hostname, 'mysql') !== FALSE) {
$this->_like_escape_str = '';
$this->_like_escape_chr = '';
} else {
if (strpos($this->hostname, 'odbc') !== FALSE) {
$this->_like_escape_str = " {escape '%s'} ";
$this->_like_escape_chr = '!';
} else {
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
}
$this->hostname = $this->hostname . ";dbname=" . $this->database;
$this->trans_enabled = FALSE;
$this->_random_keyword = ' RND(' . time() . ')';
// database specific random keyword
}
示例14: version
/**
* Database version number
*
* @return string
*/
public function version()
{
if (isset($this->data_cache['version'])) {
return $this->data_cache['version'];
}
// Not all subdrivers support the getAttribute() method
try {
return $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION);
} catch (PDOException $e) {
return parent::version();
}
}
示例15: _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;
}