mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Updated CodeIgniter to latest dev from Github
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -48,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
abstract class CI_DB_driver {
|
||||
|
||||
@@ -142,7 +142,7 @@ abstract class CI_DB_driver {
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $port = '';
|
||||
public $port = NULL;
|
||||
|
||||
/**
|
||||
* Persistent connection flag
|
||||
@@ -380,7 +380,8 @@ abstract class CI_DB_driver {
|
||||
/**
|
||||
* Initialize Database Settings
|
||||
*
|
||||
* @return bool
|
||||
* @return void
|
||||
* @throws RuntimeException In case of failure
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
@@ -392,7 +393,7 @@ abstract class CI_DB_driver {
|
||||
*/
|
||||
if ($this->conn_id)
|
||||
{
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
@@ -429,19 +430,9 @@ abstract class CI_DB_driver {
|
||||
// We still don't have a connection?
|
||||
if ( ! $this->conn_id)
|
||||
{
|
||||
log_message('error', 'Unable to connect to the database');
|
||||
|
||||
if ($this->db_debug)
|
||||
{
|
||||
$this->display_error('db_unable_to_connect');
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
throw new RuntimeException('Unable to connect to the database.');
|
||||
}
|
||||
}
|
||||
|
||||
// Now we set the character set and that's all
|
||||
return $this->db_set_charset($this->char_set);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -516,31 +507,6 @@ abstract class CI_DB_driver {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
public function db_set_charset($charset)
|
||||
{
|
||||
if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset))
|
||||
{
|
||||
log_message('error', 'Unable to set database connection charset: '.$charset);
|
||||
|
||||
if ($this->db_debug)
|
||||
{
|
||||
$this->display_error('db_unable_to_set_charset', $charset);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The name of the platform in use (mysql, mssql, etc...)
|
||||
*
|
||||
@@ -634,7 +600,6 @@ abstract class CI_DB_driver {
|
||||
// cached query if it exists
|
||||
if ($this->cache_on === TRUE && $return_object === TRUE && $this->_cache_init())
|
||||
{
|
||||
$this->load_rdriver();
|
||||
if (FALSE !== ($cache = $this->CACHE->read($sql)))
|
||||
{
|
||||
return $cache;
|
||||
@@ -718,9 +683,9 @@ abstract class CI_DB_driver {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Load and instantiate the result driver
|
||||
$driver = $this->load_rdriver();
|
||||
$RES = new $driver($this);
|
||||
// Instantiate the driver-specific result class
|
||||
$driver = 'CI_DB_'.$this->dbdriver.'_result';
|
||||
$RES = new $driver($this);
|
||||
|
||||
// Is query caching enabled? If so, we'll serialize the
|
||||
// result object and save it to a cache file.
|
||||
@@ -749,26 +714,6 @@ abstract class CI_DB_driver {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Load the result drivers
|
||||
*
|
||||
* @return string the name of the result class
|
||||
*/
|
||||
public function load_rdriver()
|
||||
{
|
||||
$driver = 'CI_DB_'.$this->dbdriver.'_result';
|
||||
|
||||
if ( ! class_exists($driver, FALSE))
|
||||
{
|
||||
require_once(BASEPATH.'database/DB_result.php');
|
||||
require_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
|
||||
}
|
||||
|
||||
return $driver;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Simple Query
|
||||
* This is a simplified version of the query() function. Internally
|
||||
@@ -780,14 +725,7 @@ abstract class CI_DB_driver {
|
||||
*/
|
||||
public function simple_query($sql)
|
||||
{
|
||||
if ( ! $this->conn_id)
|
||||
{
|
||||
if ( ! $this->initialize())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
empty($this->conn_id) && $this->initialize();
|
||||
return $this->_execute($sql);
|
||||
}
|
||||
|
||||
@@ -887,6 +825,18 @@ abstract class CI_DB_driver {
|
||||
{
|
||||
return $this->_trans_status;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns TRUE if a transaction is currently active
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function trans_active()
|
||||
{
|
||||
return (bool) $this->_trans_depth;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -1308,19 +1258,13 @@ abstract class CI_DB_driver {
|
||||
*/
|
||||
public function list_fields($table)
|
||||
{
|
||||
// Is there a cached result?
|
||||
if (isset($this->data_cache['field_names'][$table]))
|
||||
{
|
||||
return $this->data_cache['field_names'][$table];
|
||||
}
|
||||
|
||||
if (FALSE === ($sql = $this->_list_columns($table)))
|
||||
{
|
||||
return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
|
||||
}
|
||||
|
||||
$query = $this->query($sql);
|
||||
$this->data_cache['field_names'][$table] = array();
|
||||
$fields = array();
|
||||
|
||||
foreach ($query->result_array() as $row)
|
||||
{
|
||||
@@ -1342,10 +1286,10 @@ abstract class CI_DB_driver {
|
||||
}
|
||||
}
|
||||
|
||||
$this->data_cache['field_names'][$table][] = $row[$key];
|
||||
$fields[] = $row[$key];
|
||||
}
|
||||
|
||||
return $this->data_cache['field_names'][$table];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1383,10 +1327,11 @@ abstract class CI_DB_driver {
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @param mixed
|
||||
* @param mixed $item Identifier to escape
|
||||
* @param bool $split Whether to split identifiers when a dot is encountered
|
||||
* @return mixed
|
||||
*/
|
||||
public function escape_identifiers($item)
|
||||
public function escape_identifiers($item, $split = TRUE)
|
||||
{
|
||||
if ($this->_escape_char === '' OR empty($item) OR in_array($item, $this->_reserved_identifiers))
|
||||
{
|
||||
@@ -1407,22 +1352,22 @@ abstract class CI_DB_driver {
|
||||
return $item;
|
||||
}
|
||||
|
||||
static $preg_ec = array();
|
||||
static $preg_ec;
|
||||
|
||||
if (empty($preg_ec))
|
||||
{
|
||||
if (is_array($this->_escape_char))
|
||||
{
|
||||
$preg_ec = array(
|
||||
preg_quote($this->_escape_char[0], '/'),
|
||||
preg_quote($this->_escape_char[1], '/'),
|
||||
preg_quote($this->_escape_char[0]),
|
||||
preg_quote($this->_escape_char[1]),
|
||||
$this->_escape_char[0],
|
||||
$this->_escape_char[1]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char, '/');
|
||||
$preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char);
|
||||
$preg_ec[2] = $preg_ec[3] = $this->_escape_char;
|
||||
}
|
||||
}
|
||||
@@ -1431,11 +1376,13 @@ abstract class CI_DB_driver {
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?\./i', $preg_ec[2].'$1'.$preg_ec[3].'.', $item);
|
||||
return preg_replace('#'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?\.#i', $preg_ec[2].'$1'.$preg_ec[3].'.', $item);
|
||||
}
|
||||
}
|
||||
|
||||
return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?(\.)?/i', $preg_ec[2].'$1'.$preg_ec[3].'$2', $item);
|
||||
$dot = ($split !== FALSE) ? '\.' : '';
|
||||
|
||||
return preg_replace('#'.$preg_ec[0].'?([^'.$preg_ec[1].$dot.']+)'.$preg_ec[1].'?(\.)?#i', $preg_ec[2].'$1'.$preg_ec[3].'$2', $item);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1528,7 +1475,7 @@ abstract class CI_DB_driver {
|
||||
return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
|
||||
.$this->_compile_wh('qb_where')
|
||||
.$this->_compile_order_by()
|
||||
.($this->qb_limit ? ' LIMIT '.$this->qb_limit : '');
|
||||
.($this->qb_limit !== FALSE ? ' LIMIT '.$this->qb_limit : '');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1849,14 +1796,14 @@ abstract class CI_DB_driver {
|
||||
if ($offset = strripos($item, ' AS '))
|
||||
{
|
||||
$alias = ($protect_identifiers)
|
||||
? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4))
|
||||
? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4), FALSE)
|
||||
: substr($item, $offset);
|
||||
$item = substr($item, 0, $offset);
|
||||
}
|
||||
elseif ($offset = strrpos($item, ' '))
|
||||
{
|
||||
$alias = ($protect_identifiers)
|
||||
? ' '.$this->escape_identifiers(substr($item, $offset + 1))
|
||||
? ' '.$this->escape_identifiers(substr($item, $offset + 1), FALSE)
|
||||
: substr($item, $offset);
|
||||
$item = substr($item, 0, $offset);
|
||||
}
|
||||
@@ -1926,15 +1873,19 @@ abstract class CI_DB_driver {
|
||||
$i++;
|
||||
}
|
||||
|
||||
// dbprefix may've already been applied, with or without the identifier escaped
|
||||
$ec = '(?<ec>'.preg_quote(is_array($this->_escape_char) ? $this->_escape_char[0] : $this->_escape_char).')?';
|
||||
isset($ec[0]) && $ec .= '?'; // Just in case someone has disabled escaping by forcing an empty escape character
|
||||
|
||||
// Verify table prefix and replace if necessary
|
||||
if ($this->swap_pre !== '' && strpos($parts[$i], $this->swap_pre) === 0)
|
||||
if ($this->swap_pre !== '' && preg_match('#^'.$ec.preg_quote($this->swap_pre).'#', $parts[$i]))
|
||||
{
|
||||
$parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]);
|
||||
$parts[$i] = preg_replace('#^'.$ec.preg_quote($this->swap_pre).'(\S+?)#', '\\1'.$this->dbprefix.'\\2', $parts[$i]);
|
||||
}
|
||||
// We only add the table prefix if it does not already exist
|
||||
elseif (strpos($parts[$i], $this->dbprefix) !== 0)
|
||||
else
|
||||
{
|
||||
$parts[$i] = $this->dbprefix.$parts[$i];
|
||||
preg_match('#^'.$ec.preg_quote($this->dbprefix).'#', $parts[$i]) OR $parts[$i] = $this->dbprefix.$parts[$i];
|
||||
}
|
||||
|
||||
// Put the parts back together
|
||||
|
||||
Reference in New Issue
Block a user