From a2097a077474eab1b9d35acc2c93f0e99a7f12d0 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 10 Oct 2011 10:10:46 -0400 Subject: Converted database constructors to PHP5 type --- 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 a5f174f0a..52196b7ce 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -33,7 +33,7 @@ class CI_DB_utility extends CI_DB_forge { * Grabs the CI super object instance so we can access it. * */ - function CI_DB_utility() + function __construct() { // Assign the main database object to $this->db $CI =& get_instance(); -- cgit v1.2.3-24-g4f1b From f4a4bd8fac188ebc9cda822ffc811c218fd92b45 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 20 Oct 2011 12:18:42 -0500 Subject: adding new license file (OSL 3.0) and updating readme to ReST added notice of license to all source files. OSL to all except the few files we ship inside of the application folder, those are AFL. Updated license in user guide. incrementing next dev version to 3.0 due to licensing change --- system/database/DB_utility.php | 22 +++++++++++++++++----- 1 file changed, 17 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 52196b7ce..60ecb5269 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -1,13 +1,25 @@ Date: Sun, 1 Jan 2012 18:46:41 -0600 Subject: Updating copyright date to 2012 --- 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 60ecb5269..8db4f3bac 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From 24276a3a204ddf5947c66bd74f183d8058c1171e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 8 Jan 2012 02:44:38 +0200 Subject: Improve database classes --- system/database/DB_utility.php | 159 ++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 99 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 8db4f3bac..4c881d8a1 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -1,13 +1,13 @@ -db $CI =& get_instance(); $this->db =& $CI->db; - - log_message('debug', "Database Utility Class Initialized"); + log_message('debug', 'Database Utility Class Initialized'); } // -------------------------------------------------------------------- @@ -59,10 +50,9 @@ class CI_DB_utility extends CI_DB_forge { /** * List databases * - * @access public * @return bool */ - function list_databases() + public function list_databases() { // Is there a cached result? if (isset($this->data_cache['db_names'])) @@ -80,8 +70,7 @@ class CI_DB_utility extends CI_DB_forge { } } - $this->data_cache['db_names'] = $dbs; - return $this->data_cache['db_names']; + return $this->data_cache['db_names'] = $dbs; } // -------------------------------------------------------------------- @@ -89,11 +78,10 @@ class CI_DB_utility extends CI_DB_forge { /** * Determine if a particular database exists * - * @access public * @param string * @return boolean */ - function database_exists($database_name) + public function database_exists($database_name) { // Some databases won't have access to the list_databases() function, so // this is intended to allow them to override with their own functions as @@ -114,17 +102,17 @@ class CI_DB_utility extends CI_DB_forge { /** * Optimize Table * - * @access public * @param string the table name * @return bool */ - function optimize_table($table_name) + public function optimize_table($table_name) { $sql = $this->_optimize_table($table_name); if (is_bool($sql)) { - show_error('db_must_use_set'); + show_error('db_must_use_set'); + return FALSE; } $query = $this->db->query($sql); @@ -140,10 +128,9 @@ class CI_DB_utility extends CI_DB_forge { /** * Optimize Database * - * @access public * @return array */ - function optimize_database() + public function optimize_database() { $result = array(); foreach ($this->db->list_tables() as $table_name) @@ -177,11 +164,10 @@ class CI_DB_utility extends CI_DB_forge { /** * Repair Table * - * @access public * @param string the table name * @return bool */ - function repair_table($table_name) + public function repair_table($table_name) { $sql = $this->_repair_table($table_name); @@ -203,14 +189,13 @@ class CI_DB_utility extends CI_DB_forge { /** * Generate CSV from a query result object * - * @access public * @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 * @return string */ - function csv_from_result($query, $delim = ",", $newline = "\n", $enclosure = '"') + public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"') { if ( ! is_object($query) OR ! method_exists($query, 'list_fields')) { @@ -218,15 +203,13 @@ class CI_DB_utility extends CI_DB_forge { } $out = ''; - // First generate the headings from the table column names foreach ($query->list_fields() as $name) { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = rtrim($out); - $out .= $newline; + $out = rtrim($out).$newline; // Next blast through the result array and build out the rows foreach ($query->result_array() as $row) @@ -235,8 +218,7 @@ class CI_DB_utility extends CI_DB_forge { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = rtrim($out); - $out .= $newline; + $out = rtrim($out).$newline; } return $out; @@ -247,12 +229,11 @@ class CI_DB_utility extends CI_DB_forge { /** * Generate XML data from a query result object * - * @access public * @param object The query result object * @param array Any preferences * @return string */ - function xml_from_result($query, $params = array()) + public function xml_from_result($query, $params = array()) { if ( ! is_object($query) OR ! method_exists($query, 'list_fields')) { @@ -280,16 +261,14 @@ class CI_DB_utility extends CI_DB_forge { foreach ($query->result_array() as $row) { $xml .= $tab."<{$element}>".$newline; - foreach ($row as $key => $val) { $xml .= $tab.$tab."<{$key}>".xml_convert($val)."".$newline; } $xml .= $tab."".$newline; } - $xml .= "".$newline; - return $xml; + return $xml .= "".$newline; } // -------------------------------------------------------------------- @@ -297,10 +276,9 @@ class CI_DB_utility extends CI_DB_forge { /** * Database Backup * - * @access public * @return void */ - function backup($params = array()) + public function backup($params = array()) { // If the parameters have not been submitted as an // array then we know that it is simply the table @@ -314,14 +292,14 @@ class CI_DB_utility extends CI_DB_forge { // Set up our default preferences $prefs = array( - 'tables' => array(), - 'ignore' => array(), - 'filename' => '', - 'format' => 'gzip', // gzip, zip, txt - 'add_drop' => TRUE, - 'add_insert' => TRUE, - 'newline' => "\n" - ); + 'tables' => array(), + 'ignore' => array(), + 'filename' => '', + 'format' => 'gzip', // gzip, zip, txt + 'add_drop' => TRUE, + 'add_insert' => TRUE, + 'newline' => "\n" + ); // Did the user submit any preferences? If so set them.... if (count($params) > 0) @@ -335,29 +313,23 @@ class CI_DB_utility extends CI_DB_forge { } } - // ------------------------------------------------------ - // Are we backing up a complete database or individual tables? // If no table names were submitted we'll fetch the entire table list - if (count($prefs['tables']) == 0) + if (count($prefs['tables']) === 0) { $prefs['tables'] = $this->db->list_tables(); } - // ------------------------------------------------------ - // Validate the format if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE)) { $prefs['format'] = 'txt'; } - // ------------------------------------------------------ - - // Is the encoder supported? If not, we'll either issue an + // Is the encoder supported? If not, we'll either issue an // error or use plain text depending on the debug settings - if (($prefs['format'] == 'gzip' AND ! @function_exists('gzencode')) - OR ($prefs['format'] == 'zip' AND ! @function_exists('gzcompress'))) + if (($prefs['format'] === 'gzip' AND ! @function_exists('gzencode')) + OR ($prefs['format'] === 'zip' AND ! @function_exists('gzcompress'))) { if ($this->db->db_debug) { @@ -367,60 +339,49 @@ class CI_DB_utility extends CI_DB_forge { $prefs['format'] = 'txt'; } - // ------------------------------------------------------ - - // Set the filename if not provided - Only needed with Zip files - if ($prefs['filename'] == '' AND $prefs['format'] == 'zip') - { - $prefs['filename'] = (count($prefs['tables']) == 1) ? $prefs['tables'] : $this->db->database; - $prefs['filename'] .= '_'.date('Y-m-d_H-i', time()); - } - - // ------------------------------------------------------ - - // Was a Gzip file requested? - if ($prefs['format'] == 'gzip') - { - return gzencode($this->_backup($prefs)); - } - - // ------------------------------------------------------ - - // Was a text file requested? - if ($prefs['format'] == 'txt') - { - return $this->_backup($prefs); - } - - // ------------------------------------------------------ - // Was a Zip file requested? - if ($prefs['format'] == 'zip') + if ($prefs['format'] === 'zip') { - // If they included the .zip file extension we'll remove it - if (preg_match("|.+?\.zip$|", $prefs['filename'])) + // Set the filename if not provided (only needed with Zip files) + if ($prefs['filename'] == '') { - $prefs['filename'] = str_replace('.zip', '', $prefs['filename']); + $prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database) + .date('Y-m-d_H-i', time()).'.sql'; } - - // Tack on the ".sql" file extension if needed - if ( ! preg_match("|.+?\.sql$|", $prefs['filename'])) + else { - $prefs['filename'] .= '.sql'; + // If they included the .zip file extension we'll remove it + if (preg_match('|.+?\.zip$|', $prefs['filename'])) + { + $prefs['filename'] = str_replace('.zip', '', $prefs['filename']); + } + + // Tack on the ".sql" file extension if needed + if ( ! preg_match('|.+?\.sql$|', $prefs['filename'])) + { + $prefs['filename'] .= '.sql'; + } } // Load the Zip class and output it - $CI =& get_instance(); $CI->load->library('zip'); $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); return $CI->zip->get_zip(); } + elseif ($prefs['format'] == 'txt') // Was a text file requested? + { + return $this->_backup($prefs); + } + elseif ($prefs['format'] === 'gzip') // Was a Gzip file requested? + { + return gzencode($this->_backup($prefs)); + } + return; } } - /* End of file DB_utility.php */ -/* Location: ./system/database/DB_utility.php */ \ No newline at end of file +/* Location: ./system/database/DB_utility.php */ -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- 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 4c881d8a1..c94f93e5e 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 833d504a91f7c85fa2985bcff5016a052972bd7a Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 16:12:03 -0400 Subject: Made the rest of the db classes abstract \n except for the DB_cache class, because I'm not sure if it is directly called --- 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 c94f93e5e..a7db803e8 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -32,7 +32,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -class CI_DB_utility extends CI_DB_forge { +abstract class CI_DB_utility extends CI_DB_forge { public $db; public $data_cache = array(); -- cgit v1.2.3-24-g4f1b From 215890b015d219f0d31e8ad678b0b655e6923f3b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 20 Mar 2012 09:38:16 -0400 Subject: Remove extraneous newlines --- 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 a7db803e8..642a004bd 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -384,4 +384,4 @@ abstract class CI_DB_utility extends CI_DB_forge { } /* End of file DB_utility.php */ -/* Location: ./system/database/DB_utility.php */ +/* Location: ./system/database/DB_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b457a4001ce2380e97f36b0a983b477c3e31de69 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 9 Apr 2012 16:11:56 +0300 Subject: DB Utility improvements - Replaced driver methods _list_databases(), _optimize_table() and _repair_table() with properties - Added defaults for optimize_table() and repair_table() SQL strings (FALSE, as those are mostly MySQL-specific) - Added MSSQL/SQLSRV support for optimize_table() (actually rebuilds table indexes) - Switched public driver methods to protected - Improved CUBRID support for list_databases() as it used to only return the currently used database - Minor speed improvements --- system/database/DB_utility.php | 120 ++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 642a004bd..587dfdc01 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -37,6 +37,11 @@ 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 + protected $_optimize_table = FALSE; + protected $_repair_table = FALSE; + public function __construct() { // Assign the main database object to $this->db @@ -50,7 +55,7 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * List databases * - * @return bool + * @return array */ public function list_databases() { @@ -59,18 +64,25 @@ abstract class CI_DB_utility extends CI_DB_forge { { return $this->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(); - $query = $this->db->query($this->_list_databases()); - $dbs = array(); - if ($query->num_rows() > 0) + $query = $this->db->query($this->_list_databases); + if ($query === FALSE) { - foreach ($query->result_array() as $row) - { - $dbs[] = current($row); - } + return $this->data_cache['db_names']; + } + + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $this->data_cache['db_names'] = current($query[$i]); } - return $this->data_cache['db_names'] = $dbs; + return $this->data_cache['db_names']; } // -------------------------------------------------------------------- @@ -79,48 +91,36 @@ abstract class CI_DB_utility extends CI_DB_forge { * Determine if a particular database exists * * @param string - * @return boolean + * @return bool */ public function database_exists($database_name) { - // Some databases won't have access to the list_databases() function, so - // this is intended to allow them to override with their own functions as - // defined in $driver_utility.php - if (method_exists($this, '_database_exists')) - { - return $this->_database_exists($database_name); - } - else - { - return ( ! in_array($database_name, $this->list_databases())) ? FALSE : TRUE; - } + return in_array($database_name, $this->list_databases()); } - // -------------------------------------------------------------------- /** * Optimize Table * * @param string the table name - * @return bool + * @return mixed */ public function optimize_table($table_name) { - $sql = $this->_optimize_table($table_name); - - if (is_bool($sql)) + if ($this->_optimize_table === FALSE) { - show_error('db_must_use_set'); - return FALSE; + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } - $query = $this->db->query($sql); - $res = $query->result_array(); + $query = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name))); + if ($query !== FALSE) + { + $query = $query->result_array(); + return current($res); + } - // Note: Due to a bug in current() that affects some versions - // of PHP we can not pass function call directly into it - return current($res); + return FALSE; } // -------------------------------------------------------------------- @@ -128,26 +128,26 @@ abstract class CI_DB_utility extends CI_DB_forge { /** * Optimize Database * - * @return array + * @return mixed */ public function optimize_database() { + if ($this->_optimize_table === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + } + $result = array(); foreach ($this->db->list_tables() as $table_name) { - $sql = $this->_optimize_table($table_name); - - if (is_bool($sql)) + $res = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name))); + if (is_bool($res)) { - return $sql; + return $res; } - $query = $this->db->query($sql); - // Build the result array... - // Note: Due to a bug in current() that affects some versions - // of PHP we can not pass function call directly into it - $res = $query->result_array(); + $res = $res->result_array(); $res = current($res); $key = str_replace($this->db->database.'.', '', current($res)); $keys = array_keys($res); @@ -165,23 +165,23 @@ abstract class CI_DB_utility extends CI_DB_forge { * Repair Table * * @param string the table name - * @return bool + * @return mixed */ public function repair_table($table_name) { - $sql = $this->_repair_table($table_name); - - if (is_bool($sql)) + if ($this->_repair_table === FALSE) { - return $sql; + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } - $query = $this->db->query($sql); + $query = $this->db->query(sprintf($this->_repair_table, $this->db->escape_identifiers($table_name))); + if (is_bool($query)) + { + return $query; + } - // Note: Due to a bug in current() that affects some versions - // of PHP we can not pass function call directly into it - $res = $query->result_array(); - return current($res); + $query = $query->result_array(); + return current($query); } // -------------------------------------------------------------------- @@ -257,18 +257,18 @@ abstract class CI_DB_utility extends CI_DB_forge { $CI->load->helper('xml'); // Generate the result - $xml = "<{$root}>".$newline; + $xml = '<'.$root.'>'.$newline; foreach ($query->result_array() as $row) { - $xml .= $tab."<{$element}>".$newline; + $xml .= $tab.'<'.$element.'>'.$newline; foreach ($row as $key => $val) { - $xml .= $tab.$tab."<{$key}>".xml_convert($val)."".$newline; + $xml .= $tab.$tab.'<'.$key.'>'.xml_convert($val).''.$newline; } - $xml .= $tab."".$newline; + $xml .= $tab.''.$newline; } - return $xml .= "".$newline; + return $xml.''.$newline; } // -------------------------------------------------------------------- @@ -328,8 +328,8 @@ abstract class CI_DB_utility extends CI_DB_forge { // Is the encoder supported? If not, we'll either issue an // error or use plain text depending on the debug settings - if (($prefs['format'] === 'gzip' AND ! @function_exists('gzencode')) - OR ($prefs['format'] === 'zip' AND ! @function_exists('gzcompress'))) + if (($prefs['format'] === 'gzip' && ! @function_exists('gzencode')) + OR ($prefs['format'] === 'zip' && ! @function_exists('gzcompress'))) { if ($this->db->db_debug) { -- cgit v1.2.3-24-g4f1b 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 From 79494dde1c53b671f279e5c5fab2ae03a9ff0353 Mon Sep 17 00:00:00 2001 From: Andrew Podner Date: Wed, 19 Dec 2012 14:15:41 -0500 Subject: Resolves issue #2081 : provides an option to include statements to disable and re-enable foreign key checks in a MySQL database backup output statement. --- 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 c4140aef3..3ed75967e 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -326,7 +326,8 @@ abstract class CI_DB_utility { 'format' => 'gzip', // gzip, zip, txt 'add_drop' => TRUE, 'add_insert' => TRUE, - 'newline' => "\n" + 'newline' => "\n", + 'fk_checks' => TRUE ); // Did the user submit any preferences? If so set them.... -- cgit v1.2.3-24-g4f1b From 4851217a1330580ebf73f0a6fb79ad451b73759a Mon Sep 17 00:00:00 2001 From: Andrew Podner Date: Thu, 20 Dec 2012 07:56:19 -0500 Subject: fixes #2081 : change parameter/variable name to 'foreign_key_checks', update change log Signed-off-by:Andrew Podner --- system/database/DB_utility.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 3ed75967e..aff3cf8c2 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -320,14 +320,14 @@ abstract class CI_DB_utility { // Set up our default preferences $prefs = array( - 'tables' => array(), - 'ignore' => array(), - 'filename' => '', - 'format' => 'gzip', // gzip, zip, txt - 'add_drop' => TRUE, - 'add_insert' => TRUE, - 'newline' => "\n", - 'fk_checks' => TRUE + 'tables' => array(), + 'ignore' => array(), + 'filename' => '', + 'format' => 'gzip', // gzip, zip, txt + 'add_drop' => TRUE, + 'add_insert' => TRUE, + 'newline' => "\n", + 'foreign_key_checks' => TRUE ); // Did the user submit any preferences? If so set them.... -- cgit v1.2.3-24-g4f1b From 61c4d0a22e63d44bb07d9a3c5f0da030dd5b5ef9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Dec 2012 16:29:29 +0200 Subject: [ci skip] Minor style/spacing changes following PR #2087 --- system/database/DB_utility.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index aff3cf8c2..4562b973a 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -320,15 +320,15 @@ abstract class CI_DB_utility { // Set up our default preferences $prefs = array( - 'tables' => array(), - 'ignore' => array(), - 'filename' => '', - 'format' => 'gzip', // gzip, zip, txt - 'add_drop' => TRUE, - 'add_insert' => TRUE, - 'newline' => "\n", - 'foreign_key_checks' => TRUE - ); + 'tables' => array(), + 'ignore' => array(), + 'filename' => '', + 'format' => 'gzip', // gzip, zip, txt + 'add_drop' => TRUE, + 'add_insert' => TRUE, + 'newline' => "\n", + 'foreign_key_checks' => TRUE + ); // Did the user submit any preferences? If so set them.... if (count($params) > 0) -- cgit v1.2.3-24-g4f1b From 80500afbd188600212ca913a7bac073009feac73 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 1 Jan 2013 08:16:53 +0200 Subject: [ci skip] Happy new year --- 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 4562b973a..9822fdaa3 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From b76e29242fd399c47ec633152092f9ce7ac917fc Mon Sep 17 00:00:00 2001 From: Michelle Jones Date: Wed, 27 Feb 2013 16:59:48 -0500 Subject: Remove trailing delimiters from csv_from_result When using the csv_from_result function, the returned string includes an extra delimiter at the end of every line, usually a comma unless another delimiter is specified. A simple addition of a couple of lines to remove the extra delimiter from the column names and the data rows is included. (Lines 241 and 251) --- system/database/DB_utility.php | 4 +++- 1 file changed, 3 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 9822fdaa3..9803307ed 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -238,7 +238,8 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = rtrim($out).$newline; + $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names + $out = $out.$newline; // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) @@ -247,6 +248,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } + $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines $out = rtrim($out).$newline; } -- cgit v1.2.3-24-g4f1b From 31875730b3cb67e865e99e748f885c5365339c9e Mon Sep 17 00:00:00 2001 From: Michelle Jones Date: Thu, 28 Feb 2013 09:44:47 -0500 Subject: added spaces after the parameter separators --- 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 9803307ed..b270cdd4d 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -238,7 +238,7 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names + $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names $out = $out.$newline; // Next blast through the result array and build out the rows @@ -248,7 +248,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines + $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines $out = rtrim($out).$newline; } -- cgit v1.2.3-24-g4f1b From d327c797027d4ccf3bb624d7f4edd10997e372ac Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 1 Mar 2013 16:28:58 +0200 Subject: Optimize changes from PR #2290 --- system/database/DB_utility.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index b270cdd4d..9f953d4ac 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -238,8 +238,7 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names - $out = $out.$newline; + $out = substr(rtrim($out), 0, -strlen($delim)).$newline; // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) @@ -248,8 +247,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines - $out = rtrim($out).$newline; + $out = substr(rtrim($out), 0, -strlen($delim)).$newline; } return $out; -- cgit v1.2.3-24-g4f1b From 119d8a7547e155edaaa53682b9247cd7e80d8c9d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 8 Jan 2014 15:27:53 +0200 Subject: Optimize get_instance() calls/assignments --- system/database/DB_utility.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 9f953d4ac..665615909 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -282,8 +282,7 @@ abstract class CI_DB_utility { extract($params); // Load the xml helper - $CI =& get_instance(); - $CI->load->helper('xml'); + get_instance()->load->helper('xml'); // Generate the result $xml = '<'.$root.'>'.$newline; -- cgit v1.2.3-24-g4f1b From 871754af60251993d640981e107d2def5f2db396 Mon Sep 17 00:00:00 2001 From: darwinel Date: Tue, 11 Feb 2014 17:34:57 +0100 Subject: 2013 > 2014 Update copyright notices from 2013 to 2014. And update one calendar example in user_guide from year 2013/2014 to 2014/2015. --- 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 665615909..11c5e116b 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From 58e1c00275ecbe40c1fb27271650e75f80f0cf1d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 26 Feb 2014 18:51:18 +0200 Subject: More removal of error suppression usage --- 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 11c5e116b..a6961120e 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -356,8 +356,8 @@ abstract class CI_DB_utility { // Is the encoder supported? If not, we'll either issue an // error or use plain text depending on the debug settings - if (($prefs['format'] === 'gzip' && ! @function_exists('gzencode')) - OR ($prefs['format'] === 'zip' && ! @function_exists('gzcompress'))) + if (($prefs['format'] === 'gzip' && ! function_exists('gzencode')) + OR ($prefs['format'] === 'zip' && ! function_exists('gzcompress'))) { if ($this->db->db_debug) { -- cgit v1.2.3-24-g4f1b From bdb96ca1b1dbfc1791172fd169d7751cbc4d7d55 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Oct 2014 00:13:31 +0200 Subject: [ci skip] Switch to MIT license; close #3293 --- system/database/DB_utility.php | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 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 a6961120e..b2dc6da43 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -4,24 +4,35 @@ * * An open source application development framework for PHP 5.2.4 or newer * - * NOTICE OF LICENSE + * This content is released under the MIT License (MIT) * - * Licensed under the Open Software License version 3.0 + * Copyright (c) 2014, British Columbia Institute of Technology * - * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is - * also available through the world wide web at this URL: - * http://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to obtain it - * through the world wide web, please send an email to - * licensing@ellislab.com so we can send you a copy immediately. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * @package CodeIgniter - * @author EllisLab Dev Team + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @package CodeIgniter + * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * @link http://codeigniter.com - * @since Version 1.0 + * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @license http://opensource.org/licenses/MIT MIT License + * @link http://codeigniter.com + * @since Version 1.0.0 * @filesource */ defined('BASEPATH') OR exit('No direct script access allowed'); -- cgit v1.2.3-24-g4f1b From fe9309d22c1b088f5363954d6dac013c8c955894 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Jan 2015 17:48:58 +0200 Subject: Bulk (mostly documentation) update - Remove PHP version from license notices - Bump year number in copyright notices - Recommend PHP 5.4 or newer to be used - Tell Travis-CI to test on PHP 5.3.0 instead of the latest 5.3 version Related: #3450 --- system/database/DB_utility.php | 6 +++--- 1 file changed, 3 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 b2dc6da43..963080fbb 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.2.4 or newer + * An open source application development framework for PHP * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014, British Columbia Institute of Technology + * Copyright (c) 2014 - 2015, 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,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From 90726b8c769ea75aec34814ddfa91655d488e6c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Jan 2015 12:39:22 +0200 Subject: [ci skip] Change some log messages' level 'Class Loaded' type of messages flood log files when log_threshold is set to 2 (debug). They're now logged as 'info' level. This is manually applying PR #1528, which was created to do the same thing, but became outdated. --- 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 963080fbb..4bf94d4dc 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -87,7 +87,7 @@ abstract class CI_DB_utility { public function __construct(&$db) { $this->db =& $db; - log_message('debug', 'Database Utility Class Initialized'); + log_message('info', 'Database Utility Class Initialized'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 4cbe463b4c442e0e2dae2f43565e77f7ac5ecb86 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 21 Jan 2015 22:56:22 +0100 Subject: Remove closing blocks at end of PHP files --- system/database/DB_utility.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 4bf94d4dc..774d51533 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -421,6 +421,3 @@ abstract class CI_DB_utility { } } - -/* End of file DB_utility.php */ -/* Location: ./system/database/DB_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 1fb500077784638399be79b32fe354aec257413c Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Wed, 4 Feb 2015 01:45:59 +0100 Subject: Fixed inconsistent return types --- 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 774d51533..ecfda522c 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -316,7 +316,7 @@ abstract class CI_DB_utility { * Database Backup * * @param array $params - * @return void + * @return mixed */ public function backup($params = array()) { -- cgit v1.2.3-24-g4f1b From cea5fb713822d00460222deaa1cf66543effccf8 Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Wed, 4 Feb 2015 08:22:06 +0100 Subject: Adjusted returns/return types to suggestions --- 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 ecfda522c..9eac2ec41 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -316,7 +316,7 @@ abstract class CI_DB_utility { * Database Backup * * @param array $params - * @return mixed + * @return string */ public function backup($params = array()) { @@ -417,7 +417,7 @@ abstract class CI_DB_utility { return gzencode($this->_backup($prefs)); } - return; + return ''; } } -- cgit v1.2.3-24-g4f1b From 40bbd60bcc5135f898f46e502f7b04ef065274e0 Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Wed, 4 Feb 2015 14:06:47 +0100 Subject: Adjusted return type for CI_DB_utility::backup to suggestions --- 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 9eac2ec41..57356ac53 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -417,7 +417,7 @@ abstract class CI_DB_utility { return gzencode($this->_backup($prefs)); } - return ''; + return; } } -- cgit v1.2.3-24-g4f1b From b8cd5e657363795f127ae5e02e69972627b3fe9c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 May 2015 01:10:36 +0300 Subject: Fix a bug in the CSV export DB utility Reported via the forums: http://forum.codeigniter.com/thread-61810.html --- 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 57356ac53..78398ea83 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -249,7 +249,7 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + $out = substr($out, 0, -strlen($delim)).$newline; // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) @@ -258,7 +258,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + $out = substr($out, 0, -strlen($delim)).$newline; } return $out; -- cgit v1.2.3-24-g4f1b From 6d6b3b2f89d517b4589cb52965f34b115036584a Mon Sep 17 00:00:00 2001 From: Ahmad Anbar Date: Sat, 10 Oct 2015 22:51:54 +0300 Subject: Optimize csv_from_result speed. --- system/database/DB_utility.php | 5 +++-- 1 file changed, 3 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 78398ea83..b51893e18 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -254,11 +254,12 @@ abstract class CI_DB_utility { // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) { + $line = array(); foreach ($row as $item) { - $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; + $line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure; } - $out = substr($out, 0, -strlen($delim)).$newline; + $out .= implode($delim, $line).$newline; } return $out; -- cgit v1.2.3-24-g4f1b From 125ef4751080a2118cb203357d77687699e3eb25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:33:00 +0200 Subject: [ci skip] Bump year to 2016 --- 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 b51893e18..c4bad9eaf 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2015, British Columbia Institute of Technology + * Copyright (c) 2014 - 2016, 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,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From bd202c91b0e9cf0a8c93bcaa71df9574f5909346 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:50:18 +0200 Subject: [ci skip] Update codeigniter.com links to https --- 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 c4bad9eaf..619004376 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License - * @link http://codeigniter.com + * @link https://codeigniter.com * @since Version 1.0.0 * @filesource */ @@ -42,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * * @category Database * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/database/ + * @link https://codeigniter.com/user_guide/database/ */ abstract class CI_DB_utility { -- cgit v1.2.3-24-g4f1b From 1924e879b165fb119847a49a7a5eab2f28295fa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:55:34 +0200 Subject: [ci skip] Update ellislab.com links to https too --- 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 619004376..70528286c 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -28,7 +28,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com -- cgit v1.2.3-24-g4f1b From da60e9bc66ec90970fbd2dfd08b0a6e66b9f5f5f Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Sat, 31 Dec 2016 08:46:18 -0800 Subject: Update copyright data to 2017 --- 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 70528286c..25d842c09 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2016, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, 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,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) - * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b