From d06acd85cdfff5411474b46afee36fb77baa1200 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 25 May 2012 00:29:09 +0300 Subject: Added update_batch() support for PostgreSQL (issue #356) --- system/database/DB_utility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 587dfdc01..cb97ff448 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -212,7 +212,7 @@ abstract class CI_DB_utility extends CI_DB_forge { $out = rtrim($out).$newline; // Next blast through the result array and build out the rows - foreach ($query->result_array() as $row) + while ($row = $query->unbuffered_row('array')) { foreach ($row as $item) { @@ -258,7 +258,7 @@ abstract class CI_DB_utility extends CI_DB_forge { // Generate the result $xml = '<'.$root.'>'.$newline; - foreach ($query->result_array() as $row) + while ($row = $query->unbuffered_row()) { $xml .= $tab.'<'.$element.'>'.$newline; foreach ($row as $key => $val) -- cgit v1.2.3-24-g4f1b From 48a2baf0e288accd206f5da5031d29076e130792 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:09:54 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/database --- system/database/DB_utility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index cb97ff448..02c921834 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -343,7 +343,7 @@ abstract class CI_DB_utility extends CI_DB_forge { if ($prefs['format'] === 'zip') { // Set the filename if not provided (only needed with Zip files) - if ($prefs['filename'] == '') + if ($prefs['filename'] === '') { $prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database) .date('Y-m-d_H-i', time()).'.sql'; @@ -369,7 +369,7 @@ abstract class CI_DB_utility extends CI_DB_forge { $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); return $CI->zip->get_zip(); } - elseif ($prefs['format'] == 'txt') // Was a text file requested? + elseif ($prefs['format'] === 'txt') // Was a text file requested? { return $this->_backup($prefs); } -- cgit v1.2.3-24-g4f1b From 5d28176a76355b230f1c4e1858475def4e34fa4c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 22:05:40 +0300 Subject: Fix issue #1264 --- system/database/DB_utility.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 02c921834..6a3b40779 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -35,7 +35,6 @@ abstract class CI_DB_utility extends CI_DB_forge { public $db; - public $data_cache = array(); // Platform specific SQL strings // Just setting those defaults to FALSE as they are mostly MySQL-specific @@ -60,29 +59,29 @@ abstract class CI_DB_utility extends CI_DB_forge { public function list_databases() { // Is there a cached result? - if (isset($this->data_cache['db_names'])) + if (isset($this->db->data_cache['db_names'])) { - return $this->data_cache['db_names']; + return $this->db->data_cache['db_names']; } elseif ($this->_list_databases === FALSE) { return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } - $this->data_cache['db_names'] = array(); + $this->db->data_cache['db_names'] = array(); $query = $this->db->query($this->_list_databases); if ($query === FALSE) { - return $this->data_cache['db_names']; + return $this->db->data_cache['db_names']; } for ($i = 0, $c = count($query); $i < $c; $i++) { - $this->data_cache['db_names'] = current($query[$i]); + $this->db->data_cache['db_names'] = current($query[$i]); } - return $this->data_cache['db_names']; + return $this->db->data_cache['db_names']; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 5fd3ae8d33a4f5d3159b86683b9a670e973a63f5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 14:55:35 +0300 Subject: [ci skip] style and phpdoc-related changes (rel #1295) --- system/database/DB_utility.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 6a3b40779..8078e2bf6 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -41,6 +41,11 @@ abstract class CI_DB_utility extends CI_DB_forge { protected $_optimize_table = FALSE; protected $_repair_table = FALSE; + /** + * Constructor + * + * @return void + */ public function __construct() { // Assign the main database object to $this->db @@ -275,6 +280,7 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Database Backup * + * @param array $params = array() * @return void */ public function backup($params = array()) -- 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_utility.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 8078e2bf6..12680be5f 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.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_utility.php | 44 ++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 12680be5f..3bd77c84b 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -35,13 +35,31 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ abstract class CI_DB_utility extends CI_DB_forge { + /** + * Database object + * + * @var object + */ public $db; - // Platform specific SQL strings - // Just setting those defaults to FALSE as they are mostly MySQL-specific + // -------------------------------------------------------------------- + + /** + * OPTIMIZE TABLE statement + * + * @var string|bool + */ protected $_optimize_table = FALSE; + + /** + * REPAIR TABLE statement + * + * @var string|bool + */ protected $_repair_table = FALSE; + // -------------------------------------------------------------------- + /** * Constructor * @@ -95,7 +113,7 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Determine if a particular database exists * - * @param string + * @param string $database_name * @return bool */ public function database_exists($database_name) @@ -108,7 +126,7 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Optimize Table * - * @param string the table name + * @param string $table_name * @return mixed */ public function optimize_table($table_name) @@ -169,7 +187,7 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Repair Table * - * @param string the table name + * @param string $table_name * @return mixed */ public function repair_table($table_name) @@ -194,10 +212,10 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Generate CSV from a query result object * - * @param object The query result object - * @param string The delimiter - comma by default - * @param string The newline character - \n by default - * @param string The enclosure - double quote by default + * @param object $query Query result object + * @param string $delim Delimiter (default: ,) + * @param string $newline Newline character (default: \n) + * @param string $enclosure Enclosure (default: ") * @return string */ public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"') @@ -234,8 +252,8 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Generate XML data from a query result object * - * @param object The query result object - * @param array Any preferences + * @param object $query Query result object + * @param array $params Any preferences * @return string */ public function xml_from_result($query, $params = array()) @@ -281,7 +299,7 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Database Backup * - * @param array $params = array() + * @param array $params * @return void */ public function backup($params = array()) @@ -294,8 +312,6 @@ abstract class CI_DB_utility extends CI_DB_forge { $params = array('tables' => $params); } - // ------------------------------------------------------ - // Set up our default preferences $prefs = array( 'tables' => array(), -- cgit v1.2.3-24-g4f1b From c98e93aab3997bfea4fbb9d07f7b2550a84f8f7a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Nov 2012 02:04:59 +0200 Subject: [ci skip] DocBlocks for DB drivers' utility classes Partially fixes issue #1295. --- system/database/DB_utility.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 3bd77c84b..31102c0c6 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -44,24 +44,31 @@ abstract class CI_DB_utility extends CI_DB_forge { // -------------------------------------------------------------------- + /** + * List databases statement + * + * @var string + */ + $_list_databases = FALSE; + /** * OPTIMIZE TABLE statement * - * @var string|bool + * @var string */ protected $_optimize_table = FALSE; /** * REPAIR TABLE statement * - * @var string|bool + * @var string */ protected $_repair_table = FALSE; // -------------------------------------------------------------------- /** - * Constructor + * Class constructor * * @return void */ -- 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_utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 31102c0c6..f7bef6a2c 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -49,7 +49,7 @@ abstract class CI_DB_utility extends CI_DB_forge { * * @var string */ - $_list_databases = FALSE; + protected $_list_databases = FALSE; /** * OPTIMIZE TABLE statement -- cgit v1.2.3-24-g4f1b From eaa60c71082c1e49f8a48d633347c98b68a387c0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Nov 2012 01:11:22 +0200 Subject: Added possibility to pass custom database objects to DB Forge and DB Utilities Also, their property is no longer public and the utility class no longer extends CI_DB_forge. --- system/database/DB_utility.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index f7bef6a2c..a8e34c92d 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -33,14 +33,14 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -abstract class CI_DB_utility extends CI_DB_forge { +abstract class CI_DB_utility { /** * Database object * * @var object */ - public $db; + protected $db; // -------------------------------------------------------------------- @@ -70,13 +70,12 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Class constructor * + * @param object &$db Database object * @return void */ - public function __construct() + public function __construct(&$db) { - // Assign the main database object to $this->db - $CI =& get_instance(); - $this->db =& $CI->db; + $this->db =& $db; log_message('debug', 'Database Utility Class Initialized'); } -- cgit v1.2.3-24-g4f1b From 8d3afde93f9ff7f461095d5b9147b662610c045b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Nov 2012 12:53:47 +0200 Subject: Fix a lang key typo --- system/database/DB_utility.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index a8e34c92d..488ebf3ac 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -95,7 +95,7 @@ abstract class CI_DB_utility { } elseif ($this->_list_databases === FALSE) { - return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; } $this->db->data_cache['db_names'] = array(); @@ -139,7 +139,7 @@ abstract class CI_DB_utility { { if ($this->_optimize_table === FALSE) { - return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; } $query = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name))); @@ -163,7 +163,7 @@ abstract class CI_DB_utility { { if ($this->_optimize_table === FALSE) { - return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; } $result = array(); @@ -200,7 +200,7 @@ abstract class CI_DB_utility { { if ($this->_repair_table === FALSE) { - return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; } $query = $this->db->query(sprintf($this->_repair_table, $this->db->escape_identifiers($table_name))); @@ -361,7 +361,7 @@ abstract class CI_DB_utility { { if ($this->db->db_debug) { - return $this->db->display_error('db_unsuported_compression'); + return $this->db->display_error('db_unsupported_compression'); } $prefs['format'] = 'txt'; -- cgit v1.2.3-24-g4f1b From 9e94576e62e9edb5634cb3f4d278038069bb70a8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 13 Nov 2012 01:08:34 +0200 Subject: Fix issue #1994 --- system/database/DB_utility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 488ebf3ac..a32fd4455 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -106,9 +106,9 @@ abstract class CI_DB_utility { return $this->db->data_cache['db_names']; } - for ($i = 0, $c = count($query); $i < $c; $i++) + for ($i = 0, $query = $query->result_array(), $c = count($query); $i < $c; $i++) { - $this->db->data_cache['db_names'] = current($query[$i]); + $this->db->data_cache['db_names'][] = current($query[$i]); } return $this->db->data_cache['db_names']; -- cgit v1.2.3-24-g4f1b From 34cadee670f79d67942e4d8f87557c1a0b2916bc Mon Sep 17 00:00:00 2001 From: Dimitar Date: Sat, 24 Nov 2012 13:13:07 +0200 Subject: Bug fix - optimize_table() in DB utility class --- system/database/DB_utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index a32fd4455..c4140aef3 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -146,7 +146,7 @@ abstract class CI_DB_utility { if ($query !== FALSE) { $query = $query->result_array(); - return current($res); + return current($query); } return FALSE; -- cgit v1.2.3-24-g4f1b