From 87f4dc27230debc0af281c9780f2ba939fe07608 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 01:11:22 +0200 Subject: Fix an update_string() bug --- system/database/DB_driver.php | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index e8286aaa1..795ed6711 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1080,43 +1080,19 @@ abstract class CI_DB_driver { */ public function update_string($table, $data, $where) { - if ($where === '') + if (empty($where)) { return FALSE; } + $this->where($where); + $fields = array(); foreach ($data as $key => $val) { $fields[$this->protect_identifiers($key)] = $this->escape($val); } - if ( ! is_array($where)) - { - $dest = array($where); - } - else - { - $dest = array(); - foreach ($where as $key => $val) - { - $prefix = (count($dest) === 0) ? '' : ' AND '; - $key = $this->protect_identifiers($key); - - if ($val !== '') - { - if ( ! $this->_has_operator($key)) - { - $key .= ' ='; - } - - $val = ' '.$this->escape($val); - } - - $dest[] = $prefix.$key.$val; - } - } - return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest); } -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/database/DB_driver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 795ed6711..515e9cbb1 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1,4 +1,4 @@ - Date: Fri, 2 Nov 2012 01:42:31 +0200 Subject: DocBlocks for base DB classes Partially fixes issue #1295. --- system/database/DB_driver.php | 263 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 251 insertions(+), 12 deletions(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 515e9cbb1..497f8b9c9 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -41,60 +41,300 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ abstract class CI_DB_driver { + /** + * Data Source Name / Connect string + * + * @var string + */ public $dsn; + + /** + * Username + * + * @var string + */ public $username; + + /** + * Password + * + * @var string + */ public $password; + + /** + * Hostname + * + * @var string + */ public $hostname; + + /** + * Database name + * + * @var string + */ public $database; + + /** + * Database driver + * + * @var string + */ public $dbdriver = 'mysqli'; + + /** + * Sub-driver + * + * @used-by CI_DB_pdo_driver + * @var string + */ public $subdriver; + + /** + * Table prefix + * + * @var string + */ public $dbprefix = ''; + + /** + * Character set + * + * @var string + */ public $char_set = 'utf8'; + + /** + * Collation + * + * @var string + */ public $dbcollat = 'utf8_general_ci'; - public $autoinit = TRUE; // Whether to automatically initialize the DB + + /** + * Auto-init flag + * + * Whether to automatically initialize the DB connection. + * + * @var bool + */ + public $autoinit = TRUE; + + /** + * Encryption flag/data + * + * @var mixed + */ public $encrypt = FALSE; + + /** + * Swap Prefix + * + * @var string + */ public $swap_pre = ''; + + /** + * Database port + * + * @var int + */ public $port = ''; + + /** + * Persistent connection flag + * + * @var bool + */ public $pconnect = FALSE; + + /** + * Connection ID + * + * @var object|resource + */ public $conn_id = FALSE; + + /** + * Result ID + * + * @var object|resource + */ public $result_id = FALSE; + + /** + * Debug flag + * + * Whether to display error messages. + * + * @var bool + */ public $db_debug = FALSE; + + /** + * Benchmark time + * + * @var int + */ public $benchmark = 0; + + /** + * Executed queries count + * + * @var int + */ public $query_count = 0; + + /** + * Bind marker + * + * Character used to identify values in a prepared statement. + * + * @var string + */ public $bind_marker = '?'; + + /** + * Save queries flag + * + * Whether to keep an in-memory history of queries for debugging purposes. + * + * @var bool + */ public $save_queries = TRUE; + + /** + * Queries list + * + * @see CI_DB_driver::$save_queries + * @var string[] + */ public $queries = array(); + + /** + * Query times + * + * A list of times that queries took to execute. + * + * @var array + */ public $query_times = array(); + + /** + * Data cache + * + * An internal generic value cache. + * + * @var array + */ public $data_cache = array(); + /** + * Transaction enabled flag + * + * @var bool + */ public $trans_enabled = TRUE; + + /** + * Strict transaction mode flag + * + * @var bool + */ public $trans_strict = TRUE; + + /** + * Transaction depth level + * + * @var int + */ protected $_trans_depth = 0; - protected $_trans_status = TRUE; // Used with transactions to determine if a rollback should occur + /** + * Transaction status flag + * + * Used with transactions to determine if a rollback should occur. + * + * @var bool + */ + protected $_trans_status = TRUE; + + /** + * Cache On flag + * + * @var bool + */ public $cache_on = FALSE; + + /** + * Cache directory path + * + * @var bool + */ public $cachedir = ''; + + /** + * Cache auto-delete flag + * + * @var bool + */ public $cache_autodel = FALSE; - public $CACHE; // The cache class object + /** + * DB Cache object + * + * @see CI_DB_cache + * @var object + */ + public $CACHE; + + /** + * Protect identifiers flag + * + * @var bool + */ protected $_protect_identifiers = TRUE; - protected $_reserved_identifiers = array('*'); // Identifiers that should NOT be escaped - // clause and character used for LIKE escape sequences + /** + * List of reserved identifiers + * + * Identifiers that must NOT be escaped. + * + * @var string[] + */ + protected $_reserved_identifiers = array('*'); + + /** + * ESCAPE statement string + * + * @var string + */ protected $_like_escape_str = " ESCAPE '%s' "; + + /** + * ESCAPE character + * + * @var string + */ protected $_like_escape_chr = '!'; /** - * The syntax to count rows is slightly different across different - * database engines, so this string appears in each driver and is - * used for the count_all() and count_all_results() functions. + * COUNT string + * + * @used-by CI_DB_driver::count_all() + * @used-by CI_DB_query_builder::count_all_results() + * + * @var string */ protected $_count_string = 'SELECT COUNT(*) AS '; + // -------------------------------------------------------------------- + /** - * Constructor + * Class constructor * - * @param array + * @param array $params * @return void */ public function __construct($params) @@ -1175,8 +1415,7 @@ abstract class CI_DB_driver { /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * - * @param string $function the function name - * @param mixed $param,... optional parameters needed by the function + * @param string $function Function name * @return mixed */ public function call_function($function) -- cgit v1.2.3-24-g4f1b From a24e52e1c0136db0c1949e73255b4e9bf114b437 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Nov 2012 03:54:12 +0200 Subject: [ci skip] DocBlocks for DB drivers' driver classes Partially fixes issue #1295. --- system/database/DB_driver.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 497f8b9c9..39db16150 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -305,6 +305,13 @@ abstract class CI_DB_driver { */ protected $_reserved_identifiers = array('*'); + /** + * Identifier escape character + * + * @var string + */ + protected $_escape_char = '"'; + /** * ESCAPE statement string * @@ -319,6 +326,13 @@ abstract class CI_DB_driver { */ protected $_like_escape_chr = '!'; + /** + * ORDER BY random keyword + * + * @var string + */ + protected $_random_keyword = ' RAND()'; + /** * COUNT string * -- cgit v1.2.3-24-g4f1b From a7ddd2d48ec30f10250b045dbec651fc0e07532e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Nov 2012 11:53:45 +0200 Subject: Fix an escape_identifiers() bug --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 39db16150..dfaf0e0c1 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1236,7 +1236,7 @@ abstract class CI_DB_driver { */ public function escape_identifiers($item) { - if ($this->_escape_char === '' OR empty($item)) + if ($this->_escape_char === '' OR empty($item) OR in_array($item, $this->_reserved_identifiers)) { return $item; } -- cgit v1.2.3-24-g4f1b