From e70e92bab1de57a0749a31f2889b55cafb46d58e Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Mon, 25 Apr 2011 10:50:53 -0500 Subject: Fixing up a tabs vs spaces inconsistency in DB_Result --- system/database/DB_result.php | 83 +++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 39 deletions(-) (limited to 'system') diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 06eec5124..e83228386 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -32,7 +32,7 @@ class CI_DB_result { var $result_id = NULL; var $result_array = array(); var $result_object = array(); - var $custom_result_object = array(); + var $custom_result_object = array(); var $current_row = 0; var $num_rows = 0; var $row_data = NULL; @@ -47,47 +47,52 @@ class CI_DB_result { */ function result($type = 'object') { - if ($type == 'array') return $this->result_array(); - else if ($type == 'object') return $this->result_object(); - else return $this->custom_result_object($type); + if ($type == 'array') return $this->result_array(); + else if ($type == 'object') return $this->result_object(); + else return $this->custom_result_object($type); } // -------------------------------------------------------------------- - /** - * Custom query result. - * - * @param class_name A string that represents the type of object you want back - * @return array of objects - */ - function custom_result_object($class_name) - { - if (array_key_exists($class_name, $this->custom_result_object)) - { - return $this->custom_result_object[$class_name]; - } - - if ($this->result_id === FALSE OR $this->num_rows() == 0) - { - return array(); - } - - // add the data to the object - $this->_data_seek(0); - $result_object = array(); + /** + * Custom query result. + * + * @param class_name A string that represents the type of object you want back + * @return array of objects + */ + function custom_result_object($class_name) + { + if (array_key_exists($class_name, $this->custom_result_object)) + { + return $this->custom_result_object[$class_name]; + } + + if ($this->result_id === FALSE OR $this->num_rows() == 0) + { + return array(); + } + + // add the data to the object + $this->_data_seek(0); + $result_object = array(); + while ($row = $this->_fetch_object()) - { - $object = new $class_name(); - foreach ($row as $key => $value) - { - $object->$key = $value; - } + { + $object = new $class_name(); + + foreach ($row as $key => $value) + { + $object->$key = $value; + } + $result_object[] = $object; } - // return the array - return $this->custom_result_object[$class_name] = $result_object; - } + // return the array + return $this->custom_result_object[$class_name] = $result_object; + } + + // -------------------------------------------------------------------- /** * Query result. "object" version. @@ -180,9 +185,9 @@ class CI_DB_result { $n = 0; } - if ($type == 'object') return $this->row_object($n); - else if ($type == 'array') return $this->row_array($n); - else return $this->custom_row_object($n, $type); + if ($type == 'object') return $this->row_object($n); + else if ($type == 'array') return $this->row_array($n); + else return $this->custom_row_object($n, $type); } // -------------------------------------------------------------------- @@ -219,7 +224,7 @@ class CI_DB_result { // -------------------------------------------------------------------- - /** + /** * Returns a single result row - custom object version * * @access public @@ -242,7 +247,7 @@ class CI_DB_result { return $result[$this->current_row]; } - /** + /** * Returns a single result row - object version * * @access public -- cgit v1.2.3-24-g4f1b From 2e0a49e8573aca9c63e72d7e7dcd3b0867b3dc81 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Mon, 25 Apr 2011 15:00:45 -0500 Subject: swapping out preg_replace() in the driver library where str_replace() works just fine. --- system/libraries/Driver.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index b90b5aba6..1e01fcc1f 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -43,11 +43,11 @@ class CI_Driver_Library { // The class will be prefixed with the parent lib $child_class = $this->lib_name.'_'.$child; - + // Remove the CI_ prefix and lowercase - $lib_name = ucfirst(strtolower(preg_replace('/^CI_/', '', $this->lib_name))); - $driver_name = strtolower(preg_replace('/^CI_/', '', $child_class)); - + $lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name))); + $driver_name = strtolower(str_replace('CI_', '', $child_class)); + if (in_array($driver_name, array_map('strtolower', $this->valid_drivers))) { // check and see if the driver is in a separate file -- cgit v1.2.3-24-g4f1b From 689f95d2c8bcbd0ac2f538c237dff471fbcff048 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 26 Apr 2011 09:59:29 -0400 Subject: Automatic base_url generation was missing a ending slash. --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Config.php b/system/core/Config.php index fa71f4d3d..55c623b3c 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -55,7 +55,7 @@ class CI_Config { { $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST']; - $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']).'/'; } else -- cgit v1.2.3-24-g4f1b From 5d1e32b2fbae74e6f9e1ab2bdb6a3635579ef13e Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 3 May 2011 22:28:59 -0400 Subject: Added unit tests for date helper. --- system/helpers/date_helper.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index f3f01f751..951181b8c 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -112,15 +112,16 @@ if ( ! function_exists('standard_date')) function standard_date($fmt = 'DATE_RFC822', $time = '') { $formats = array( - 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q', + 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O', 'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC', - 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q', + 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O', 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O', - 'DATE_RFC850' => '%l, %d-%M-%y %H:%m:%i UTC', + 'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC', 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O', 'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O', + 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O', 'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O', - 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q' + 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%O' ); if ( ! isset($formats[$fmt])) -- cgit v1.2.3-24-g4f1b From 827f3de2733e85ede6311feb2e4bf73ecf209eb3 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Fri, 6 May 2011 11:29:57 -0500 Subject: Fixed a regression where a PHP error could occur when using some methods. --- system/database/DB_active_rec.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 508f6bedf..83d481699 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -204,6 +204,7 @@ class CI_DB_active_record extends CI_DB_driver { $sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$alias; $this->ar_select[] = $sql; + $this->ar_no_escape[] = NULL; if ($this->ar_caching === TRUE) { -- cgit v1.2.3-24-g4f1b From 2e00c2490fb544596fba06483ad1c1d626c1fd4f Mon Sep 17 00:00:00 2001 From: Stephen Date: Sun, 28 Aug 2011 10:25:40 +0200 Subject: Added tests for CI_URI class. Made modifications to core class which helped with isolation for testing. --- system/core/URI.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/URI.php b/system/core/URI.php index a3ae20cc3..51c2191af 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -87,7 +87,7 @@ class CI_URI { if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') { // Is the request coming from the command line? - if (php_sapi_name() == 'cli' or defined('STDIN')) + if ($this->_is_cli_request()) { $this->_set_uri_string($this->_parse_cli_args()); return; @@ -222,6 +222,21 @@ class CI_URI { return str_replace(array('//', '../'), '/', trim($uri, '/')); } + // -------------------------------------------------------------------- + + /** + * Is cli Request? + * + * Duplicate of function from the Input class to test to see if a request was made from the command line + * + * @return boolean + */ + protected function _is_cli_request() + { + return (php_sapi_name() == 'cli') OR defined('STDIN'); + } + + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From f08548b2b88324c36729a7dd4d179a9e1076dc14 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 6 Sep 2011 17:40:17 -0400 Subject: Fixed int typecasting of limit parameter in DB_active_rec.php If an empty string was passed, the typecast was changing it to 0. This produced "LIMIT 0" which returned no results. This must be a bug and not a feature because there are other params after limit in both $this->db->limit and $this->db->get. --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 841ede28e..a16363c68 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -874,7 +874,7 @@ class CI_DB_active_record extends CI_DB_driver { */ public function limit($value, $offset = '') { - $this->ar_limit = (int) $value; + $this->ar_limit = $value; if ($offset != '') { -- cgit v1.2.3-24-g4f1b From 8ff2da1c7457cfd04a28776705cea64cbb96716a Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 23 Nov 2011 10:09:57 +0100 Subject: tmp_path does not exists, should be tmp_name --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 05511b5d3..fe5907ab2 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1055,7 +1055,7 @@ class CI_Upload { if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec')) { $output = array(); - @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code); + @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_name']), $output, $return_code); if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution { $this->file_type = rtrim($output[0]); -- cgit v1.2.3-24-g4f1b From 511f225d855919b78df42ff802a513d84afa0693 Mon Sep 17 00:00:00 2001 From: Túbal Martín Date: Thu, 24 Nov 2011 14:43:45 +0100 Subject: Added dummy _reset_select() method to CI_DB_Driver class to allow Active Record class to be disabled. Otherwise a fatal error is triggered. --- system/database/DB_driver.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 3680b85c2..8f530b482 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1381,7 +1381,21 @@ class CI_DB_driver { return $item.$alias; } + + // -------------------------------------------------------------------- + /** + * Dummy method that allows Active Record class to be disabled + * + * This function is used extensively by every db driver. + * + * @access private + * @return void + */ + protected function _reset_select() + { + + } } -- cgit v1.2.3-24-g4f1b From 9a05d2b0d838bb000a89ab9ea78a307b557768e7 Mon Sep 17 00:00:00 2001 From: John Nicely Date: Thu, 24 Nov 2011 10:50:39 -0800 Subject: Changed form_open() to compare $action against base_url() Checking for strpos($action, $CI->config->site_url()) === FALSE causes CSRF token to not be added in form_open() output. When site_url()'s first parameter ($uri) is empty, site_url's return value is the base URL plus the $CI->config->item('index_page') value. form_open() and CodeIgniter's URI routing do not require index.php to be in the URL, so any call to form_open() in which the $action parameter does not have index.php will always return false for the strpos() call. --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index d9305c00b..8733ae053 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -65,7 +65,7 @@ if ( ! function_exists('form_open')) $form .= '>'; // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites - if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"'))) + if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"'))) { $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } -- cgit v1.2.3-24-g4f1b From d92bd57f007e9561a37be8a8ccaf93a4f8948343 Mon Sep 17 00:00:00 2001 From: Repox Date: Thu, 1 Dec 2011 10:08:52 +0100 Subject: This fixes issue #725 --- system/database/DB_driver.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 3680b85c2..3952d7276 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1015,8 +1015,14 @@ class CI_DB_driver { else { $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null; - - return call_user_func_array($function, $args); + if (is_null($args)) + { + return call_user_func($function); + } + else + { + return call_user_func_array($function, $args); + } } } -- cgit v1.2.3-24-g4f1b From 59654319d20a7ec406e7d6f15cf6804e94897d14 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Dec 2011 14:28:54 +0200 Subject: Hotfix for a file type detection bug in the Upload library --- system/libraries/Upload.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index fe5907ab2..ff3461586 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1042,14 +1042,17 @@ class CI_Upload { if (function_exists('mime_content_type')) { $this->file_type = @mime_content_type($file['tmp_name']); - return; + if (strlen($this->file_type) > 0) // Turned out it's possible ... + { + return; + } } /* This is an ugly hack, but UNIX-type systems provide a native way to detect the file type, * which is still more secure than depending on the value of $_FILES[$field]['type']. * * Notes: - * - a 'W' in the substr() expression bellow, would mean that we're using Windows + * - the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system * - many system admins would disable the exec() function due to security concerns, hence the function_exists() check */ if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec')) -- cgit v1.2.3-24-g4f1b From f796655d37163e7fd046395ddfe765baf752ec77 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Dec 2011 15:00:36 +0200 Subject: Update a comment, just to be clearer --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index ff3461586..506d15897 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1042,7 +1042,7 @@ class CI_Upload { if (function_exists('mime_content_type')) { $this->file_type = @mime_content_type($file['tmp_name']); - if (strlen($this->file_type) > 0) // Turned out it's possible ... + if (strlen($this->file_type) > 0) // Turns out it's possible that mime_content_type() returns FALSE or an empty string { return; } -- cgit v1.2.3-24-g4f1b From a49e381fde010a7a83845910c0f772fb139f0b1e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Dec 2011 13:05:22 +0200 Subject: Improve CI_Upload::_file_mime_type() --- system/libraries/Upload.php | 102 +++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 506d15897..564d6000e 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1018,50 +1018,104 @@ class CI_Upload { */ protected function _file_mime_type($file) { - // Use if the Fileinfo extension, if available (only versions above 5.3 support the FILEINFO_MIME_TYPE flag) - if ( (float) substr(phpversion(), 0, 3) >= 5.3 && function_exists('finfo_file')) + // We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii) + $regexp = '/^([a-z\-]+\/[a-z0-9\-]+);\s.+$/'; + + /* Fileinfo extension - most reliable method + * + * Unfortunately, prior to PHP 5.3 - it's only available as a PECL extension and the + * more convenient FILEINFO_MIME_TYPE flag doesn't exist. + */ + if (function_exists('finfo_file')) { - $finfo = new finfo(FILEINFO_MIME_TYPE); - if ($finfo !== FALSE) // This is possible, if there is no magic MIME database file found on the system + $finfo = finfo_open(FILEINFO_MIME); + if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system { - $file_type = $finfo->file($file['tmp_name']); + $mime = @finfo_file($finfo, $file['tmp_name']); + finfo_close($finfo); /* According to the comments section of the PHP manual page, * it is possible that this function returns an empty string * for some files (e.g. if they don't exist in the magic MIME database) */ - if (strlen($file_type) > 1) + if (is_string($mime) && preg_match($regexp, $mime, $matches)) { - $this->file_type = $file_type; + $this->file_type = $matches[1]; return; } } } - // Fall back to the deprecated mime_content_type(), if available - if (function_exists('mime_content_type')) + /* This is an ugly hack, but UNIX-type systems provide a "native" way to detect the file type, + * which is still more secure than depending on the value of $_FILES[$field]['type'], and as it + * was reported in issue #750 (https://github.com/EllisLab/CodeIgniter/issues/750) - it's better + * than mime_content_type() as well, hence the attempts to try calling the command line with + * three different functions. + * + * Notes: + * - the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system + * - many system admins would disable the exec(), shell_exec(), popen() and similar functions + * due to security concerns, hence the function_exists() checks + */ + if (DIRECTORY_SEPARATOR !== '\\') { - $this->file_type = @mime_content_type($file['tmp_name']); - if (strlen($this->file_type) > 0) // Turns out it's possible that mime_content_type() returns FALSE or an empty string + $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1'; + + if (function_exists('exec')) { - return; + /* This might look confusing, as $mime is being populated with all of the output when set in the second parameter. + * However, we only neeed the last line, which is the actual return value of exec(), and as such - it overwrites + * anything that could already be set for $mime previously. This effectively makes the second parameter a dummy + * value, which is only put to allow us to get the return status code. + */ + $mime = @exec($cmd, $mime, $return_status); + if ($return_status === 0 && is_string($mime) && preg_match($regexp, $mime, $matches)) + { + $this->file_type = $matches[1]; + return; + } + } + + if ( (bool) @ini_get('safe_mode') === FALSE && function_exists('shell_exec')) + { + $mime = @shell_exec($cmd); + if (strlen($mime) > 0) + { + $mime = explode("\n", trim($mime)); + if (preg_match($regexp, $mime[(count($mime) - 1)], $matches)) + { + $this->file_type = $matches[1]; + return; + } + } + } + + if (function_exists('popen')) + { + $proc = @popen($cmd, 'r'); + if (is_resource($proc)) + { + $mime = @fread($test, 512); + @pclose($proc); + if ($mime !== FALSE) + { + $mime = explode("\n", trim($mime)); + if (preg_match($regexp, $mime[(count($mime) - 1)], $matches)) + { + $this->file_type = $matches[1]; + return; + } + } + } } } - /* This is an ugly hack, but UNIX-type systems provide a native way to detect the file type, - * which is still more secure than depending on the value of $_FILES[$field]['type']. - * - * Notes: - * - the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system - * - many system admins would disable the exec() function due to security concerns, hence the function_exists() check - */ - if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec')) + // Fall back to the deprecated mime_content_type(), if available (still better than $_FILES[$field]['type']) + if (function_exists('mime_content_type')) { - $output = array(); - @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_name']), $output, $return_code); - if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution + $this->file_type = @mime_content_type($file['tmp_name']); + if (strlen($this->file_type) > 0) // It's possible that mime_content_type() returns FALSE or an empty string { - $this->file_type = rtrim($output[0]); return; } } -- cgit v1.2.3-24-g4f1b From 750ffb9f6d545772c7139b5ee0c1402241c6ceb2 Mon Sep 17 00:00:00 2001 From: Andrew Mackrodt Date: Sat, 10 Dec 2011 23:42:07 +0000 Subject: Fix for Issue #538. --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 8902f524d..7f905128b 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -208,7 +208,7 @@ class CI_Image_lib { } else { - if (strpos($this->new_image, '/') === FALSE) + if (strpos($this->new_image, '/') === FALSE AND strpos($this->new_image, '\\') === FALSE) { $this->dest_folder = $this->source_folder; $this->dest_image = $this->new_image; -- cgit v1.2.3-24-g4f1b From 3b6ff4ddc5ca433ba7b68a51a617c00b93511889 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Dec 2011 14:57:36 +0200 Subject: Fix regular expression for validating MIME type string --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 564d6000e..c72fa3c6d 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1019,7 +1019,7 @@ class CI_Upload { protected function _file_mime_type($file) { // We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii) - $regexp = '/^([a-z\-]+\/[a-z0-9\-]+);\s.+$/'; + $regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+);\s.+$/'; /* Fileinfo extension - most reliable method * -- cgit v1.2.3-24-g4f1b From f7aed129051475b4baeeb549a764464560c9dd34 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 13 Dec 2011 11:01:06 +0200 Subject: Tweak MIME regular expression check again --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index c72fa3c6d..91fbf66ca 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1019,7 +1019,7 @@ class CI_Upload { protected function _file_mime_type($file) { // We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii) - $regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+);\s.+$/'; + $regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/'; /* Fileinfo extension - most reliable method * -- cgit v1.2.3-24-g4f1b From 0ea392937fd9e0a135e16cc7a645e4068f456f5d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 18:48:46 +0200 Subject: Improve the Zip library --- system/libraries/Zip.php | 70 +++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 52f1bc3d0..3c66c6b3a 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -1,13 +1,13 @@ -now); - - $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; - $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; + + $time = array( + 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2, + 'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'] + ); return $time; } @@ -117,7 +119,7 @@ class CI_Zip { * @param string the directory name * @return void */ - function _add_dir($dir, $file_mtime, $file_mdate) + private function _add_dir($dir, $file_mtime, $file_mdate) { $dir = str_replace("\\", "/", $dir); @@ -170,21 +172,19 @@ class CI_Zip { * @param string * @return void */ - function add_data($filepath, $data = NULL) + public function add_data($filepath, $data = NULL) { if (is_array($filepath)) { foreach ($filepath as $path => $data) { $file_data = $this->_get_mod_time($path); - $this->_add_data($path, $data, $file_data['file_mtime'], $file_data['file_mdate']); } } else { $file_data = $this->_get_mod_time($filepath); - $this->_add_data($filepath, $data, $file_data['file_mtime'], $file_data['file_mdate']); } } @@ -199,7 +199,7 @@ class CI_Zip { * @param string the data to be encoded * @return void */ - function _add_data($filepath, $data, $file_mtime, $file_mdate) + private function _add_data($filepath, $data, $file_mtime, $file_mdate) { $filepath = str_replace("\\", "/", $filepath); @@ -251,7 +251,7 @@ class CI_Zip { * @access public * @return bool */ - function read_file($path, $preserve_filepath = FALSE) + public function read_file($path, $preserve_filepath = FALSE) { if ( ! file_exists($path)) { @@ -286,7 +286,7 @@ class CI_Zip { * @param string path to source * @return bool */ - function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) + public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { if ( ! $fp = @opendir($path)) { @@ -301,7 +301,7 @@ class CI_Zip { while (FALSE !== ($file = readdir($fp))) { - if (substr($file, 0, 1) == '.') + if ($file[0] === '.') { continue; } @@ -337,7 +337,7 @@ class CI_Zip { * @access public * @return binary string */ - function get_zip() + public function get_zip() { // Is there any data to return? if ($this->entries == 0) @@ -345,15 +345,13 @@ class CI_Zip { return FALSE; } - $zip_data = $this->zipdata; - $zip_data .= $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00"; - $zip_data .= pack('v', $this->entries); // total # of entries "on this disk" - $zip_data .= pack('v', $this->entries); // total # of entries overall - $zip_data .= pack('V', strlen($this->directory)); // size of central dir - $zip_data .= pack('V', strlen($this->zipdata)); // offset to start of central dir - $zip_data .= "\x00\x00"; // .zip file comment length - - return $zip_data; + return $this->zipdata + . $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00" + . pack('v', $this->entries) // total # of entries "on this disk" + . pack('v', $this->entries) // total # of entries overall + . pack('V', strlen($this->directory)) // size of central dir + . pack('V', strlen($this->zipdata)) // offset to start of central dir + . "\x00\x00"; // .zip file comment length } // -------------------------------------------------------------------- @@ -367,7 +365,7 @@ class CI_Zip { * @param string the file name * @return bool */ - function archive($filepath) + public function archive($filepath) { if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE))) { @@ -392,7 +390,7 @@ class CI_Zip { * @param string the data to be encoded * @return bool */ - function download($filename = 'backup.zip') + public function download($filename = 'backup.zip') { if ( ! preg_match("|.+?\.zip$|", $filename)) { @@ -420,7 +418,7 @@ class CI_Zip { * @access public * @return void */ - function clear_data() + public function clear_data() { $this->zipdata = ''; $this->directory = ''; @@ -432,4 +430,4 @@ class CI_Zip { } /* End of file Zip.php */ -/* Location: ./system/libraries/Zip.php */ \ No newline at end of file +/* Location: ./system/libraries/Zip.php */ -- cgit v1.2.3-24-g4f1b From b9535c80cc389952912f456f2c68665398b71494 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:21:17 +0200 Subject: Update with suggestions from gaker & dixy --- system/libraries/Zip.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 3c66c6b3a..7a97914c0 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -97,7 +97,7 @@ class CI_Zip { * @param string path to file * @return array filemtime/filemdate */ - private function _get_mod_time($dir) + protected function _get_mod_time($dir) { // filemtime() may return false, but raises an error for non-existing files $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now); @@ -115,11 +115,11 @@ class CI_Zip { /** * Add Directory * - * @access private + * @access protected * @param string the directory name * @return void */ - private function _add_dir($dir, $file_mtime, $file_mdate) + protected function _add_dir($dir, $file_mtime, $file_mdate) { $dir = str_replace("\\", "/", $dir); @@ -194,12 +194,12 @@ class CI_Zip { /** * Add Data to Zip * - * @access private + * @access protected * @param string the file name/path * @param string the data to be encoded * @return void */ - private function _add_data($filepath, $data, $file_mtime, $file_mdate) + protected function _add_data($filepath, $data, $file_mtime, $file_mdate) { $filepath = str_replace("\\", "/", $filepath); @@ -288,6 +288,8 @@ class CI_Zip { */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { + $path = rtrim($path, '/\\').DIRECTORY_SEPARATOR; + if ( ! $fp = @opendir($path)) { return FALSE; @@ -425,6 +427,7 @@ class CI_Zip { $this->entries = 0; $this->file_num = 0; $this->offset = 0; + return $this; } } -- cgit v1.2.3-24-g4f1b From b1f3f57c65083904fe899753043419a25b073898 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:38:39 +0200 Subject: Remove access lines from method descriptions --- system/libraries/Zip.php | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 7a97914c0..d60b99462 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -68,7 +68,6 @@ class CI_Zip { * * Lets you add a virtual directory into which you can place files. * - * @access public * @param mixed the directory name. Can be string or array * @return void */ @@ -115,7 +114,6 @@ class CI_Zip { /** * Add Directory * - * @access protected * @param string the directory name * @return void */ @@ -167,7 +165,6 @@ class CI_Zip { * in the filename it will be placed within a directory. Make * sure you use add_dir() first to create the folder. * - * @access public * @param mixed * @param string * @return void @@ -194,7 +191,6 @@ class CI_Zip { /** * Add Data to Zip * - * @access protected * @param string the file name/path * @param string the data to be encoded * @return void @@ -248,7 +244,6 @@ class CI_Zip { /** * Read the contents of a file and add it to the zip * - * @access public * @return bool */ public function read_file($path, $preserve_filepath = FALSE) @@ -282,7 +277,6 @@ class CI_Zip { * sub-folders) and creates a zip based on it. Whatever directory structure * is in the original file path will be recreated in the zip file. * - * @access public * @param string path to source * @return bool */ @@ -336,7 +330,6 @@ class CI_Zip { /** * Get the Zip file * - * @access public * @return binary string */ public function get_zip() @@ -363,7 +356,6 @@ class CI_Zip { * * Lets you write a file * - * @access public * @param string the file name * @return bool */ @@ -387,7 +379,6 @@ class CI_Zip { /** * Download * - * @access public * @param string the file name * @param string the data to be encoded * @return bool @@ -417,7 +408,6 @@ class CI_Zip { * Lets you clear current zip data. Useful if you need to create * multiple zips with different data. * - * @access public * @return void */ public function clear_data() -- cgit v1.2.3-24-g4f1b From 24abcb98d4281dcf857cb08a86a58af286a2f94a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Jan 2012 20:40:15 +0200 Subject: Numerous improvements to the Oracle (oci8) driver and DB_driver --- system/database/DB_driver.php | 242 ++++------ system/database/drivers/oci8/oci8_driver.php | 82 +--- system/database/drivers/oci8/oci8_forge.php | 45 +- system/database/drivers/oci8/oci8_result.php | 624 ++++++++++++++++++++++++-- system/database/drivers/oci8/oci8_utility.php | 36 +- 5 files changed, 741 insertions(+), 288 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 661b42ced..41d170875 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1,13 +1,13 @@ -_db_set_charset($this->char_set, $this->dbcollat)) { @@ -227,10 +222,9 @@ class CI_DB_driver { /** * The name of the platform in use (mysql, mssql, etc...) * - * @access public * @return string */ - function platform() + public function platform() { return $this->dbdriver; } @@ -241,10 +235,9 @@ class CI_DB_driver { * Database Version Number. Returns a string containing the * version of the database being used * - * @access public * @return string */ - function version() + public function version() { if (FALSE === ($sql = $this->_version())) { @@ -281,12 +274,11 @@ class CI_DB_driver { * FALSE upon failure, and if the $db_debug variable is set to TRUE * will raise an error. * - * @access public * @param string An SQL query string * @param array An array of binding data * @return mixed */ - function query($sql, $binds = FALSE, $return_object = TRUE) + public function query($sql, $binds = FALSE, $return_object = TRUE) { if ($sql == '') { @@ -410,23 +402,21 @@ class CI_DB_driver { } // Load and instantiate the result driver - $driver = $this->load_rdriver(); $RES = new $driver(); - $RES->conn_id = $this->conn_id; - $RES->result_id = $this->result_id; + $RES->conn_id = $this->conn_id; + $RES->result_id = $this->result_id; if ($this->dbdriver == 'oci8') { $RES->stmt_id = $this->stmt_id; - $RES->curs_id = NULL; + $RES->curs_id = $this->curs_id; $RES->limit_used = $this->limit_used; + // Passing the next one by reference to make sure it's updated, if needed: + $RES->commit_mode = &$this->_commit; $this->stmt_id = FALSE; } - // oci8 vars must be set before calling this - $RES->num_rows = $RES->num_rows(); - // Is query caching enabled? If so, we'll serialize the // result object and save it to a cache file. if ($this->cache_on == TRUE AND $this->_cache_init()) @@ -438,9 +428,9 @@ class CI_DB_driver { // result object, so we'll have to compile the data // and save it) $CR = new CI_DB_result(); - $CR->num_rows = $RES->num_rows(); $CR->result_object = $RES->result_object(); $CR->result_array = $RES->result_array(); + $CR->num_rows = $RES->num_rows(); // Reset these since cached objects can not utilize resource IDs. $CR->conn_id = NULL; @@ -457,10 +447,9 @@ class CI_DB_driver { /** * Load the result drivers * - * @access public * @return string the name of the result class */ - function load_rdriver() + public function load_rdriver() { $driver = 'CI_DB_'.$this->dbdriver.'_result'; @@ -481,11 +470,10 @@ class CI_DB_driver { * we only use it when running transaction commands since they do * not require all the features of the main query() function. * - * @access public * @param string the sql query * @return mixed */ - function simple_query($sql) + public function simple_query($sql) { if ( ! $this->conn_id) { @@ -504,7 +492,7 @@ class CI_DB_driver { * @access public * @return void */ - function trans_off() + public function trans_off() { $this->trans_enabled = FALSE; } @@ -521,7 +509,7 @@ class CI_DB_driver { * @access public * @return void */ - function trans_strict($mode = TRUE) + public function trans_strict($mode = TRUE) { $this->trans_strict = is_bool($mode) ? $mode : TRUE; } @@ -531,10 +519,9 @@ class CI_DB_driver { /** * Start Transaction * - * @access public * @return void */ - function trans_start($test_mode = FALSE) + public function trans_start($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -557,10 +544,9 @@ class CI_DB_driver { /** * Complete Transaction * - * @access public * @return bool */ - function trans_complete() + public function trans_complete() { if ( ! $this->trans_enabled) { @@ -604,10 +590,9 @@ class CI_DB_driver { /** * Lets you retrieve the transaction flag to determine if it has failed * - * @access public * @return bool */ - function trans_status() + public function trans_status() { return $this->_trans_status; } @@ -617,12 +602,11 @@ class CI_DB_driver { /** * Compile Bindings * - * @access public * @param string the sql statement * @param array an array of bind data * @return string */ - function compile_binds($sql, $binds) + public function compile_binds($sql, $binds) { if (strpos($sql, $this->bind_marker) === FALSE) { @@ -660,11 +644,10 @@ class CI_DB_driver { /** * Determines if a query is a "write" type. * - * @access public * @param string An SQL query string * @return boolean */ - function is_write_type($sql) + public function is_write_type($sql) { if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql)) { @@ -678,11 +661,10 @@ class CI_DB_driver { /** * Calculate the aggregate query elapsed time * - * @access public * @param integer The number of decimal places * @return integer */ - function elapsed_time($decimals = 6) + public function elapsed_time($decimals = 6) { return number_format($this->benchmark, $decimals); } @@ -692,10 +674,9 @@ class CI_DB_driver { /** * Returns the total number of queries * - * @access public * @return integer */ - function total_queries() + public function total_queries() { return $this->query_count; } @@ -705,10 +686,9 @@ class CI_DB_driver { /** * Returns the last query that was executed * - * @access public * @return void */ - function last_query() + public function last_query() { return end($this->queries); } @@ -721,11 +701,10 @@ class CI_DB_driver { * Escapes data based on type * Sets boolean and null types * - * @access public * @param string * @return mixed */ - function escape($str) + public function escape($str) { if (is_string($str)) { @@ -751,11 +730,10 @@ class CI_DB_driver { * Calls the individual driver for platform * specific escaping for LIKE conditions * - * @access public * @param string * @return mixed */ - function escape_like_str($str) + public function escape_like_str($str) { return $this->escape_str($str, TRUE); } @@ -768,11 +746,10 @@ class CI_DB_driver { * Retrieves the primary key. It assumes that the row in the first * position is the primary key * - * @access public * @param string the table name * @return string */ - function primary($table = '') + public function primary($table = '') { $fields = $this->list_fields($table); @@ -789,10 +766,9 @@ class CI_DB_driver { /** * Returns an array of table names * - * @access public * @return array */ - function list_tables($constrain_by_prefix = FALSE) + public function list_tables($constrain_by_prefix = FALSE) { // Is there a cached result? if (isset($this->data_cache['table_names'])) @@ -835,12 +811,12 @@ class CI_DB_driver { /** * Determine if a particular table exists - * @access public + * * @return boolean */ - function table_exists($table_name) + public function table_exists($table_name) { - return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE; + return in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables()); } // -------------------------------------------------------------------- @@ -848,11 +824,10 @@ class CI_DB_driver { /** * Fetch MySQL Field Names * - * @access public * @param string the table name * @return array */ - function list_fields($table = '') + public function list_fields($table = '') { // Is there a cached result? if (isset($this->data_cache['field_names'][$table])) @@ -901,14 +876,14 @@ class CI_DB_driver { /** * Determine if a particular field exists - * @access public + * * @param string * @param string * @return boolean */ - function field_exists($field_name, $table_name) + public function field_exists($field_name, $table_name) { - return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE; + return in_array($field_name, $this->list_fields($table_name)); } // -------------------------------------------------------------------- @@ -916,11 +891,10 @@ class CI_DB_driver { /** * Returns an object with field data * - * @access public * @param string the table name * @return object */ - function field_data($table = '') + public function field_data($table = '') { if ($table == '') { @@ -932,7 +906,6 @@ class CI_DB_driver { } $query = $this->query($this->_field_data($this->_protect_identifiers($table, TRUE, NULL, FALSE))); - return $query->field_data(); } @@ -941,12 +914,11 @@ class CI_DB_driver { /** * Generate an insert string * - * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @return string */ - function insert_string($table, $data) + public function insert_string($table, $data) { $fields = array(); $values = array(); @@ -965,13 +937,12 @@ class CI_DB_driver { /** * Generate an update string * - * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @param mixed the "where" statement * @return string */ - function update_string($table, $data, $where) + public function update_string($table, $data, $where) { if ($where == '') { @@ -1018,19 +989,12 @@ class CI_DB_driver { /** * Tests whether the string has an SQL operator * - * @access private * @param string * @return bool */ - function _has_operator($str) + protected function _has_operator($str) { - $str = trim($str); - if ( ! preg_match("/(\s|<|>|!|=|is null|is not null)/i", $str)) - { - return FALSE; - } - - return TRUE; + return (bool) preg_match('/(\s|<|>|!|=|is null|is not null)/i', trim($str)); } // -------------------------------------------------------------------- @@ -1038,12 +1002,11 @@ class CI_DB_driver { /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * - * @access public * @param string the function name * @param mixed any parameters needed by the function * @return mixed */ - function call_function($function) + public function call_function($function) { $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_'; @@ -1080,11 +1043,10 @@ class CI_DB_driver { /** * Set Cache Directory Path * - * @access public * @param string the path to the cache directory * @return void */ - function cache_set_path($path = '') + public function cache_set_path($path = '') { $this->cachedir = $path; } @@ -1094,13 +1056,11 @@ class CI_DB_driver { /** * Enable Query Caching * - * @access public * @return void */ - function cache_on() + public function cache_on() { - $this->cache_on = TRUE; - return TRUE; + return $this->cache_on = TRUE; } // -------------------------------------------------------------------- @@ -1108,13 +1068,11 @@ class CI_DB_driver { /** * Disable Query Caching * - * @access public * @return void */ - function cache_off() + public function cache_off() { - $this->cache_on = FALSE; - return FALSE; + return $this->cache_on = FALSE; } @@ -1123,10 +1081,9 @@ class CI_DB_driver { /** * Delete the cache files associated with a particular URI * - * @access public * @return void */ - function cache_delete($segment_one = '', $segment_two = '') + public function cache_delete($segment_one = '', $segment_two = '') { if ( ! $this->_cache_init()) { @@ -1140,10 +1097,9 @@ class CI_DB_driver { /** * Delete All cache files * - * @access public * @return void */ - function cache_delete_all() + public function cache_delete_all() { if ( ! $this->_cache_init()) { @@ -1158,22 +1114,18 @@ class CI_DB_driver { /** * Initialize the Cache Class * - * @access private * @return void */ - function _cache_init() + private function _cache_init() { if (is_object($this->CACHE) AND class_exists('CI_DB_Cache')) { return TRUE; } - if ( ! class_exists('CI_DB_Cache')) + if ( ! class_exists('CI_DB_Cache') AND ! @include(BASEPATH.'database/DB_cache.php')) { - if ( ! @include(BASEPATH.'database/DB_cache.php')) - { - return $this->cache_off(); - } + return $this->cache_off(); } $this->CACHE = new CI_DB_Cache($this); // pass db object to support multiple db connections and returned db objects @@ -1185,10 +1137,9 @@ class CI_DB_driver { /** * Close DB Connection * - * @access public * @return void */ - function close() + public function close() { if (is_resource($this->conn_id) OR is_object($this->conn_id)) { @@ -1202,13 +1153,12 @@ class CI_DB_driver { /** * Display an error message * - * @access public * @param string the error message * @param string any "swap" values * @param boolean whether to localize the message * @return string sends the application/error_db.php template */ - function display_error($error = '', $swap = '', $native = FALSE) + public function display_error($error = '', $swap = '', $native = FALSE) { $LANG =& load_class('Lang', 'core'); $LANG->load('db'); @@ -1254,11 +1204,10 @@ class CI_DB_driver { * * This function adds backticks if appropriate based on db type * - * @access private * @param mixed the item to escape * @return mixed the item with backticks */ - function protect_identifiers($item, $prefix_single = FALSE) + public function protect_identifiers($item, $prefix_single = FALSE) { return $this->_protect_identifiers($item, $prefix_single); } @@ -1285,14 +1234,14 @@ class CI_DB_driver { * insert the table prefix (if it exists) in the proper position, and escape only * the correct identifiers. * - * @access private + * @access public (DB Forge needs it to be public!) * @param string * @param bool * @param mixed * @param bool * @return string */ - function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) + public function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) { if ( ! is_bool($protect_identifiers)) { @@ -1440,6 +1389,5 @@ class CI_DB_driver { } - /* End of file DB_driver.php */ /* Location: ./system/database/DB_driver.php */ diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index c6621901b..cc9557e7d 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -1,13 +1,13 @@ -stmt_id = FALSE; $this->_set_stmt_id($sql); oci_set_prefetch($this->stmt_id, 1000); @@ -187,7 +181,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Generate a statement ID * - * @access private * @param string an SQL query * @return none */ @@ -206,7 +199,6 @@ class CI_DB_oci8_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ @@ -220,7 +212,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * getCursor. Returns a cursor from the datbase * - * @access public * @return cursor id */ public function get_cursor() @@ -234,7 +225,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Stored Procedure. Executes a stored procedure * - * @access public * @param package package stored procedure is in * @param procedure stored procedure to execute * @param params array of parameters @@ -287,7 +277,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Bind parameters * - * @access private * @return none */ private function _bind_params($params) @@ -316,7 +305,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ public function trans_begin($test_mode = FALSE) @@ -337,7 +325,7 @@ class CI_DB_oci8_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; - $this->_commit = OCI_DEFAULT; + $this->_commit = (is_php('5.3.2')) ? OCI_NO_AUTO_COMMIT : OCI_DEFAULT; return TRUE; } @@ -346,7 +334,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ public function trans_commit() @@ -362,9 +349,8 @@ class CI_DB_oci8_driver extends CI_DB { return TRUE; } - $ret = oci_commit($this->conn_id); $this->_commit = OCI_COMMIT_ON_SUCCESS; - return $ret; + return oci_commit($this->conn_id); } // -------------------------------------------------------------------- @@ -372,7 +358,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ public function trans_rollback() @@ -388,9 +373,8 @@ class CI_DB_oci8_driver extends CI_DB { return TRUE; } - $ret = oci_rollback($this->conn_id); $this->_commit = OCI_COMMIT_ON_SUCCESS; - return $ret; + return oci_rollback($this->conn_id); } // -------------------------------------------------------------------- @@ -398,7 +382,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string @@ -434,7 +417,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ public function affected_rows() @@ -447,7 +429,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Insert ID * - * @access public * @return integer */ public function insert_id() @@ -464,7 +445,6 @@ class CI_DB_oci8_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ @@ -494,7 +474,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access protected * @param boolean * @return string */ @@ -517,7 +496,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access protected * @param string the table name * @return string */ @@ -533,7 +511,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ @@ -547,7 +524,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message string * - * @access protected * @return string */ protected function _error_message() @@ -562,7 +538,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message number * - * @access protected * @return integer */ protected function _error_number() @@ -579,7 +554,6 @@ class CI_DB_oci8_driver extends CI_DB { * * This function escapes column and table names * - * @access protected * @param string * @return string */ @@ -622,7 +596,6 @@ class CI_DB_oci8_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access protected * @param type * @return type */ @@ -643,7 +616,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values @@ -688,7 +660,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access protected * @param string the table name * @param array the update data * @param array the where clause @@ -705,12 +676,10 @@ class CI_DB_oci8_driver extends CI_DB { $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - - $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); - - $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + $orderby = (count($orderby) > 0) ? ' ORDER BY '.implode(', ', $orderby) : ''; + $sql = 'UPDATE '.$table.' SET '.implode(', ', $valstr); + $sql .= ($where != '' AND count($where) > 0) ? ' WHERE '.implode(' ', $where) : ''; $sql .= $orderby.$limit; return $sql; @@ -725,7 +694,6 @@ class CI_DB_oci8_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access protected * @param string the table name * @return string */ @@ -741,7 +709,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access protected * @param string the table name * @param array the where clause * @param string the limit clause @@ -775,7 +742,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access protected * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value @@ -802,7 +768,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Close DB Connection * - * @access protected * @param resource * @return void */ @@ -811,10 +776,7 @@ class CI_DB_oci8_driver extends CI_DB { @oci_close($conn_id); } - } - - /* End of file oci8_driver.php */ /* Location: ./system/database/drivers/oci8/oci8_driver.php */ diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index b4a24cdca..6975f2a5f 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -1,13 +1,13 @@ -db->_protect_identifiers($field); - - $sql .= ' '.$attributes['TYPE']; + $sql .= "\n\t".$this->db->_protect_identifiers($field).' '.$attributes['TYPE']; if (array_key_exists('CONSTRAINT', $attributes)) { @@ -127,11 +124,6 @@ class CI_DB_oci8_forge extends CI_DB_forge { { $sql .= ' NOT NULL'; } - - if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) - { - $sql .= ' AUTO_INCREMENT'; - } } // don't add a comma on the end of the last field @@ -174,12 +166,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Drop Table * - * @access private - * @return bool + * @return string */ - function _drop_table($table) + public function _drop_table($table) { - return FALSE; + return 'DROP TABLE ' . $this->db->_protect_identifiers($table); } // -------------------------------------------------------------------- @@ -190,7 +181,6 @@ class CI_DB_oci8_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -198,9 +188,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the default value * @param boolean should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); @@ -242,12 +232,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); return $sql; @@ -257,4 +246,4 @@ class CI_DB_oci8_forge extends CI_DB_forge { } /* End of file oci8_forge.php */ -/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/oci8/oci8_forge.php */ diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 0f69fa9ef..cbf4bec52 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -1,13 +1,13 @@ -num_rows === 0 && count($this->result_array()) > 0) + if ( ! is_int($this->num_rows)) { - $this->num_rows = count($this->result_array()); - @oci_execute($this->stmt_id, OCI_DEFAULT); - - if ($this->curs_id) + if (count($this->result_array) > 0) + { + return $this->num_rows = count($this->result_array); + } + elseif (count($this->result_object) > 0) { - @oci_execute($this->curs_id, OCI_DEFAULT); + return $this->num_rows = count($this->result_array); } + + return $this->num_rows = count($this->result_array()); } return $this->num_rows; @@ -73,7 +82,6 @@ class CI_DB_oci8_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ public function num_fields() @@ -83,7 +91,7 @@ class CI_DB_oci8_result extends CI_DB_result { // if we used a limit we subtract it if ($this->limit_used) { - $count = $count - 1; + return $count - 1; } return $count; @@ -96,7 +104,6 @@ class CI_DB_oci8_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ public function list_fields() @@ -116,7 +123,6 @@ class CI_DB_oci8_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ public function field_data() @@ -140,7 +146,7 @@ class CI_DB_oci8_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ public function free_result() { @@ -149,6 +155,17 @@ class CI_DB_oci8_result extends CI_DB_result { oci_free_statement($this->result_id); $this->result_id = FALSE; } + + if (is_resource($this->stmt_id)) + { + oci_free_statement($this->stmt_id); + } + + if (is_resource($this->curs_id)) + { + oci_cancel($this->curs_id); + $this->curs_id = NULL; + } } // -------------------------------------------------------------------- @@ -158,7 +175,6 @@ class CI_DB_oci8_result extends CI_DB_result { * * Returns the result set as an array * - * @access protected * @return array */ protected function _fetch_assoc() @@ -174,22 +190,47 @@ class CI_DB_oci8_result extends CI_DB_result { * * Returns the result set as an object * - * @access protected * @return object */ protected function _fetch_object() { $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id; - return @oci_fetch_object($id); + return oci_fetch_object($id); + } + + // -------------------------------------------------------------------- + + /* Query result + * + * Acts as a wrapper for result_array(), result_object() + * and custom_result_object(). + * + * @param string ('object', 'array' or a custom class name) + * @return array + */ + + public function result($type = 'object') + { + if ($type === 'object') + { + return $this->result_object(); + } + elseif ($type === 'array') + { + return $this->result_array(); + } + else + { + return $this->custom_result_object($type); + } } // -------------------------------------------------------------------- /** - * Query result. "array" version. + * Query result. "array" version. * - * @access public - * @return array + * @return array */ public function result_array() { @@ -197,14 +238,488 @@ class CI_DB_oci8_result extends CI_DB_result { { return $this->result_array; } + elseif (count($this->result_object) > 0) + { + for ($i = 0, $c = count($this->result_object); $i < $c; $i++) + { + $this->result_array[$i] = (array) $this->result_object[$i]; + } + + return $this->result_array; + } + elseif (is_array($this->row_data)) + { + if (count($this->row_data) === 0) + { + return $this->result_array; + } + else + { + $row_index = count($this->row_data); + } + } + else + { + $row_index = 0; + $this->row_data = array(); + } $row = NULL; while ($row = $this->_fetch_assoc()) { - $this->result_array[] = $row; + $this->row_data[$row_index++] = $row; + } + + // Un-comment the following line, in case it becomes needed + // $this->_data_seek(); + return $this->result_array = $this->row_data; + } + + // -------------------------------------------------------------------- + + /** + * Query result. "object" version. + * + * @return array + */ + public function result_object() + { + if (count($this->result_object) > 0) + { + return $this->result_object; + } + elseif (count($this->result_array) > 0) + { + for ($i = 0, $c = count($this->result_array); $i < $c; $i++) + { + $this->result_object[] = (object) $this->result_array[$i]; + } + + return $this->result_object; + } + elseif (is_array($this->row_data)) + { + if (count($this->row_data) === 0) + { + return $this->result_object; + } + else + { + $row_index = count($this->row_data); + for ($i = 0; $i < $row_index; $i++) + { + $this->result_object[$i] = (object) $this->row_data[$i]; + } + } + } + else + { + $row_index = 0; + $this->row_data = array(); + } + + $row = NULL; + while ($row = $this->_fetch_object()) + { + $this->row_data[$row_index] = (array) $row; + $this->result_object[$row_index++] = $row; + } + + // Un-comment the following line, in case it becomes needed + // $this->_data_seek(); + return $this->result_object; + } + + // -------------------------------------------------------------------- + + /** + * Query result. Custom object version. + * + * @param string class name used to instantiate rows to + * @return array + */ + public function custom_result_object($class_name) + { + if (array_key_exists($class_name, $this->custom_result_object)) + { + return $this->custom_result_object[$class_name]; + } + + if ( ! class_exists($class_name) OR $this->result_id === FALSE OR $this->num_rows() === 0) + { + return array(); + } + + // add the data to the object + $result_object = array(); + $data = NULL; + + /* First check if we don't already have the data. + * If so - pass by reference, as we don't know how + * large it might be and we don't want 1000 row + * sets being copied. + */ + if (count($this->result_array) > 0) + { + $data = &$this->result_array; + } + elseif (count($this->result_object) > 0) + { + $data = &$this->result_object; + } + + if ( ! is_null($data)) + { + for ($i = 0, $c = count($data); $i < $c; $i++) + { + $result_object[$i] = new $class_name(); + foreach ($data[$i] as $key => $value) + { + $result_object[$i]->$key = $value; + } + } + } + else + { + // No prefetched result set + if (is_array($this->row_data)) + { + $row_index = count($this->row_data); + if ($row_index === 0) + { + return array(); + } + else + { + for ($i = 0; $i < $row_index; $i++) + { + $result_object[$i] = new $class_name(); + foreach ($this->row_data[$i] as $key => $value) + { + $result_object[$i]->$key = $value; + } + } + } + } + else + { + $row_index = 0; + $this->row_data = array(); + } + + while ($row = $this->_fetch_assoc()) + { + $data = new $class_name(); + foreach ($row as $key => $value) + { + $data->$key = $value; + } + + $this->row_data[$row_index] = $row; + $result_object[$row_index++] = $data; + } + // Un-comment the following line, in case it becomes needed + // $this->_data_seek(); + } + + /* As described for the num_rows() method - there's no easy + * way to get the number of rows selected. Our work-around + * solution (as in here as well) first checks if result_array + * or result_object exist and returns their count. It doesn't + * however check for a custom_object_result, so - do it here. + */ + if ( ! is_int($this->num_rows)) + { + $this->num_rows = count($result_object); + } + + // Cache and return the array + return $this->custom_result_object[$class_name] = $result_object; + } + + // -------------------------------------------------------------------- + + /* Single row result. + * + * Acts as a wrapper for row_object(), row_array() + * and custom_row_object(). Also used by first_row(), next_row() + * and previous_row(). + * + * @param int row index + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + + public function row($n = 0, $type = 'object') + { + if ($type === 'object') return $this->row_object($n); + elseif ($type === 'array') return $this->row_array($n); + else return $this->custom_row_object($n, $type); + } + + // -------------------------------------------------------------------- + + /* Single row result. Array version. + * + * @param int row index + * @return array + */ + + public function row_array($n = 0) + { + // Make sure $n is not a string + if ( ! is_int($n)) + { + $n = (int) $n; } - return $this->result_array; + /* If row_data is initialized, it means that we've already tried + * (at least) to fetch some data, so ... check if we already have + * this row. + */ + if (is_array($this->row_data)) + { + /* If we already have row_data[$n] - return it. + * + * If we enter the elseif, there's a number of reasons to + * return an empty array: + * + * - count($this->row_data) === 0 means there are no results + * - num_rows being set, result_array and/or result_object + * having count() > 0 means that we've already fetched all + * data and $n is greater than our highest row index available + * - $n < $this->current_row means that if such row existed, + * we would've already returned it, therefore $n is an + * invalid index + */ + if (isset($this->row_data[$n])) // We already have this row + { + $this->current_row = $n; + return $this->row_data[$n]; + } + elseif (count($this->row_data) === 0 OR is_int($this->num_rows) + OR count($this->result_array) > 0 OR count($this->result_object) > 0 + OR $n < $this->current_row) + { + // No such row exists + return array(); + } + + // Get the next row index that would actually need to be fetched + $current_row = ($this->current_row < count($this->row_data)) ? count($this->row_data) : $this->current_row + 1; + } + else + { + $current_row = $this->current_row = 0; + $this->row_data = array(); + } + + /* Fetch more data, if available + * + * NOTE: Operator precedence is important here, if you change + * 'AND' with '&&' - it WILL BREAK the results, as + * $row will be assigned the scalar value of both + * expressions! + */ + while ($row = $this->_fetch_assoc() AND $current_row <= $n) + { + $this->row_data[$current_row++] = $row; + } + + // This would mean that there's no (more) data to fetch + if ( ! is_array($this->row_data) OR ! isset($this->row_data[$n])) + { + // Cache what we already have + if (is_array($this->row_data)) + { + $this->num_rows = count($this->row_data); + /* Usually, row_data could have less elements than result_array, + * but at this point - they should be exactly the same. + */ + $this->result_array = $this->row_data; + } + else + { + $this->num_rows = 0; + } + + return array(); + } + + $this->current_row = $n; + return $this->row_data[$n]; + } + + // -------------------------------------------------------------------- + + /* Single row result. Object version. + * + * @param int row index + * @return mixed object if row found; empty array if not + */ + public function row_object($n = 0) + { + // Make sure $n is not a string + if ( ! is_int($n)) + { + $n = (int) $n; + } + /* Logic here is exactly the same as in row_array, + * except we have to cast row_data[$n] to an object. + * + * If we already have result_object though - we can + * directly return from it. + */ + if (isset($this->result_object[$n])) + { + $this->current_row = $n; + // Set this, if not already done. + if ( ! is_int($this->num_rows)) + { + $this->num_rows = count($this->result_object); + } + + return $this->result_object[$n]; + } + + $row = $this->row_array($n); + // Cast only if the row exists + if (count($row) > 0) + { + $this->current_row = $n; + return (object) $row; + } + + return array(); + } + + // -------------------------------------------------------------------- + + /* Single row result. Custom object version. + * + * @param int row index + * @param string custom class name + * @return mixed custom object if row found; empty array otherwise + */ + + public function custom_row_object($n = 0, $class_name) + { + // Make sure $n is not a string + if ( ! is_int($n)) + { + $n = (int) $n; + } + + if (array_key_exists($class_name, $this->custom_result_object)) + { + /* We already have a the whole result set with this class_name, + * return the specified row if it exists, and an empty array if + * it doesn't. + */ + if (isset($this->custom_result_object[$class_name][$n])) + { + $this->current_row = $n; + return $this->custom_result_object[$class_name][$n]; + } + else + { + return array(); + } + } + elseif ( ! class_exists($class_name)) // No such class exists + { + return array(); + } + + $row = $this->row_array($n); + // An array would mean that the row doesn't exist + if (is_array($row)) + { + return $row; + } + + // Convert to the desired class and return + $row_object = new $class_name(); + foreach ($row as $key => $value) + { + $row_object->$key = $value; + } + + $this->current_row = $n; + return $row_object; + } + + // -------------------------------------------------------------------- + + /* First row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + + public function first_row($type = 'object') + { + return $this->row(0, $type); + } + + // -------------------------------------------------------------------- + + /* Last row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function last_row($type = 'object') + { + $result = &$this->result($type); + if ( ! isset($this->num_rows)) + { + $this->num_rows = count($result); + } + $this->current_row = $this->num_rows - 1; + return $result[$this->current_row]; + } + + // -------------------------------------------------------------------- + + /* Next row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function next_row($type = 'object') + { + if (is_array($this->row_data)) + { + $count = count($this->row_data); + if ($this->current_row > $count OR ($this->current_row === 0 && $count === 0)) + { + $n = $count; + } + else + { + $n = $this->current_row + 1; + } + } + else + { + $n = 0; + } + + return $this->row($n, $type); + } + + // -------------------------------------------------------------------- + + /* Previous row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function previous_row($type = 'object') + { + $n = ($this->current_row !== 0) ? $this->current_row - 1 : 0; + return $this->row($n, $type); } // -------------------------------------------------------------------- @@ -212,20 +727,59 @@ class CI_DB_oci8_result extends CI_DB_result { /** * Data Seek * - * Moves the internal pointer to the desired offset. We call + * Moves the internal pointer to the desired offset. We call * this internally before fetching results to make sure the - * result set starts at zero + * result set starts at zero. * - * @access protected - * @return array + * Oracle's PHP extension doesn't have an easy way of doing this + * and the only workaround is to (re)execute the statement or cursor + * in order to go to the first (zero) index of the result set. + * Then, we would need to "dummy" fetch ($n - 1) rows to get to the + * right one. + * + * This is as ridiculous as it sounds and it's the reason why every + * other method that is fetching data tries to use an already "cached" + * result set. Keeping this just in case it becomes needed at + * some point in the future, but it will only work for resetting the + * pointer to zero. + * + * @return bool */ - protected function _data_seek($n = 0) + protected function _data_seek() { - return FALSE; // Not needed + /* The PHP manual says that if OCI_NO_AUTO_COMMIT mode + * is used, and oci_rollback() and/or oci_commit() are + * not subsequently called - this will cause an unnecessary + * rollback to be triggered at the end of the script execution. + * + * Therefore we'll try to avoid using that mode flag + * if we're not currently in the middle of a transaction. + */ + if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS) + { + $result = @oci_execute($this->stmt_id, $this->commit_mode); + } + else + { + $result = @oci_execute($this->stmt_id); + } + + if ($result && $this->curs_id) + { + if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS) + { + return @oci_execute($this->curs_id, $this->commit_mode); + } + else + { + return @oci_execute($this->curs_id); + } + } + + return $result; } } - /* End of file oci8_result.php */ /* Location: ./system/database/drivers/oci8/oci8_result.php */ diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index d60f98bc4..317ff91eb 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -1,13 +1,13 @@ -db->display_error('db_unsuported_feature'); } + } /* End of file oci8_utility.php */ -/* Location: ./system/database/drivers/oci8/oci8_utility.php */ \ No newline at end of file +/* Location: ./system/database/drivers/oci8/oci8_utility.php */ -- cgit v1.2.3-24-g4f1b From 7b62bff30cd80b6ddde4489f8a59948766334c20 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Jan 2012 20:43:57 +0200 Subject: Fix a method description --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 41d170875..e667c25d3 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -822,7 +822,7 @@ class CI_DB_driver { // -------------------------------------------------------------------- /** - * Fetch MySQL Field Names + * Fetch Field Names * * @param string the table name * @return array -- cgit v1.2.3-24-g4f1b From 6ea08e60670e4bb7ce184b695d515626d472489d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Jan 2012 21:43:17 +0200 Subject: Fix issue 413 --- system/database/drivers/oci8/oci8_driver.php | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index cc9557e7d..dea08ffe4 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -528,8 +528,7 @@ class CI_DB_oci8_driver extends CI_DB { */ protected function _error_message() { - // If the error was during connection, no conn_id should be passed - $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); + $error = self::_get_error_data(); return $error['message']; } @@ -542,13 +541,35 @@ class CI_DB_oci8_driver extends CI_DB { */ protected function _error_number() { - // Same as _error_message() - $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); + $error = self::_get_error_data(); return $error['code']; } // -------------------------------------------------------------------- + /* Get error data + * + * Used by _error_message() and _error_number() + * + * @return array + */ + private function _get_error_data() + { + $res = NULL; + foreach (array('curs_id', 'stmt_id', 'conn_id') as $key) + { + if (is_resource($this->$key)) + { + $res = $key; + break; + } + } + + return ( ! is_null($res)) ? oci_error($res) : oci_error(); + } + + // -------------------------------------------------------------------- + /** * Escape the SQL Identifiers * -- cgit v1.2.3-24-g4f1b From 6684ce5c7957b1095ad137faa981e80723f5e848 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Jan 2012 22:05:14 +0200 Subject: Really fix error handling :) --- system/database/drivers/oci8/oci8_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index dea08ffe4..f520f7c76 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -560,7 +560,7 @@ class CI_DB_oci8_driver extends CI_DB { { if (is_resource($this->$key)) { - $res = $key; + $res = $this->$key; break; } } -- cgit v1.2.3-24-g4f1b From f1b43d43385c81788dab9103a4f9be7e02432852 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 6 Jan 2012 14:41:50 +0200 Subject: Improve array, captcha & cookie helpers --- system/helpers/array_helper.php | 27 ++++---------- system/helpers/captcha_helper.php | 78 ++++++++++++++------------------------- system/helpers/cookie_helper.php | 17 +++------ 3 files changed, 39 insertions(+), 83 deletions(-) (limited to 'system') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index c46c4d103..881f57db3 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -1,13 +1,13 @@ - $val) { - if ( ! is_array($data)) + if ( ! is_array($data) && ( ! isset($$key) OR $$key == '')) { - if ( ! isset($$key) OR $$key == '') - { - $$key = $val; - } + $$key = $val; } else { @@ -70,22 +67,7 @@ if ( ! function_exists('create_captcha')) } } - if ($img_path == '' OR $img_url == '') - { - return FALSE; - } - - if ( ! @is_dir($img_path)) - { - return FALSE; - } - - if ( ! is_writable($img_path)) - { - return FALSE; - } - - if ( ! extension_loaded('gd')) + if ($img_path == '' OR $img_url == '' OR ! @is_dir($img_path) OR ! is_writeable($img_path) OR ! extension_loaded('gd')) { return FALSE; } @@ -94,21 +76,16 @@ if ( ! function_exists('create_captcha')) // Remove old images // ----------------------------------- - list($usec, $sec) = explode(" ", microtime()); + list($usec, $sec) = explode(' ', microtime()); $now = ((float)$usec + (float)$sec); $current_dir = @opendir($img_path); - while ($filename = @readdir($current_dir)) { - if ($filename != "." and $filename != ".." and $filename != "index.html") + if ($filename !== '.' && $filename !== '..' && $filename !== 'index.html' + && (str_replace('.jpg', '', $filename) + $expiration) < $now) { - $name = str_replace(".jpg", "", $filename); - - if (($name + $expiration) < $now) - { - @unlink($img_path.$filename); - } + @unlink($img_path.$filename); } } @@ -118,18 +95,17 @@ if ( ! function_exists('create_captcha')) // Do we have a "word" yet? // ----------------------------------- - if ($word == '') - { + if ($word == '') + { $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $str = ''; - for ($i = 0; $i < 8; $i++) + $word = ''; + for ($i = 0, $mt_rand_max = strlen($pool) - 1; $i < 8; $i++) { - $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1); + $word .= substr($pool, mt_rand(0, $mt_rand_max), 1); } - $word = $str; - } + } // ----------------------------------- // Determine angle and position @@ -138,7 +114,7 @@ if ( ! function_exists('create_captcha')) $length = strlen($word); $angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0; $x_axis = rand(6, (360/$length)-16); - $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height); + $y_axis = ($angle >= 0) ? rand($img_height, $img_width) : rand(6, $img_height); // ----------------------------------- // Create image @@ -180,18 +156,18 @@ if ( ! function_exists('create_captcha')) $circles = 20; $points = 32; - for ($i = 0; $i < ($circles * $points) - 1; $i++) + for ($i = 0, $cp = $circles * $points; $i < $cp - 1; $i++) { - $theta = $theta + $thetac; - $rad = $radius * ($i / $points ); + $theta += $thetac; + $rad = $radius * ($i / $points); $x = ($rad * cos($theta)) + $x_axis; $y = ($rad * sin($theta)) + $y_axis; - $theta = $theta + $thetac; + $theta += $thetac; $rad1 = $radius * (($i + 1) / $points); $x1 = ($rad1 * cos($theta)) + $x_axis; - $y1 = ($rad1 * sin($theta )) + $y_axis; + $y1 = ($rad1 * sin($theta)) + $y_axis; imageline($im, $x, $y, $x1, $y1, $grid_color); - $theta = $theta - $thetac; + $theta -= $thetac; } // ----------------------------------- @@ -213,18 +189,18 @@ if ( ! function_exists('create_captcha')) $y = $font_size+2; } - for ($i = 0; $i < strlen($word); $i++) + for ($i = 0; $i < $length; $i++) { if ($use_font == FALSE) { $y = rand(0 , $img_height/2); - imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color); + imagestring($im, $font_size, $x, $y, $word[$i], $text_color); $x += ($font_size*2); } else { $y = rand($img_height/2, $img_height-3); - imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1)); + imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, $word[$i]); $x += $font_size; } } @@ -255,4 +231,4 @@ if ( ! function_exists('create_captcha')) // ------------------------------------------------------------------------ /* End of file captcha_helper.php */ -/* Location: ./system/helpers/captcha_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/captcha_helper.php */ diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 7b439c47f..d6f836670 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -1,13 +1,13 @@ -input->cookie($prefix.$index, $xss_clean); } @@ -110,6 +104,5 @@ if ( ! function_exists('delete_cookie')) } } - /* End of file cookie_helper.php */ -/* Location: ./system/helpers/cookie_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/cookie_helper.php */ -- cgit v1.2.3-24-g4f1b From cfbd15b6d052c1cb93fb5fa08e35fa7d3c6c7751 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 8 Jan 2012 06:41:41 +0200 Subject: Some more misc. stuff --- system/libraries/Zip.php | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index d60b99462..2ed79f0e3 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -51,13 +51,9 @@ class CI_Zip { public $offset = 0; public $now; - /** - * Constructor - */ public function __construct() { - log_message('debug', "Zip Compression Class Initialized"); - + log_message('debug', 'Zip Compression Class Initialized'); $this->now = time(); } @@ -75,13 +71,12 @@ class CI_Zip { { foreach ((array)$directory as $dir) { - if ( ! preg_match("|.+/$|", $dir)) + if ( ! preg_match('|.+/$|', $dir)) { $dir .= '/'; } $dir_time = $this->_get_mod_time($dir); - $this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']); } } @@ -101,12 +96,10 @@ class CI_Zip { // filemtime() may return false, but raises an error for non-existing files $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now); - $time = array( + return array( 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2, 'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'] ); - - return $time; } // -------------------------------------------------------------------- @@ -197,13 +190,11 @@ class CI_Zip { */ protected function _add_data($filepath, $data, $file_mtime, $file_mdate) { - $filepath = str_replace("\\", "/", $filepath); + $filepath = str_replace('\\', '/', $filepath); $uncompressed_size = strlen($data); $crc32 = crc32($data); - - $gzdata = gzcompress($data); - $gzdata = substr($gzdata, 2, -4); + $gzdata = substr(gzcompress($data), 2, -4); $compressed_size = strlen($gzdata); $this->zipdata .= @@ -255,16 +246,16 @@ class CI_Zip { if (FALSE !== ($data = file_get_contents($path))) { - $name = str_replace("\\", "/", $path); - + $name = str_replace('\\', '/', $path); if ($preserve_filepath === FALSE) { - $name = preg_replace("|.*/(.+)|", "\\1", $name); + $name = preg_replace('|.*/(.+)|', '\\1', $name); } $this->add_data($name, $data); return TRUE; } + return FALSE; } @@ -282,7 +273,7 @@ class CI_Zip { */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { - $path = rtrim($path, '/\\').DIRECTORY_SEPARATOR; + $path = rtrim($path, '/\\').'/'; if ( ! $fp = @opendir($path)) { @@ -304,14 +295,13 @@ class CI_Zip { if (@is_dir($path.$file)) { - $this->read_dir($path.$file."/", $preserve_filepath, $root_path); + $this->read_dir($path.$file.'/', $preserve_filepath, $root_path); } else { if (FALSE !== ($data = file_get_contents($path.$file))) { - $name = str_replace("\\", "/", $path); - + $name = str_replace('\\', '/', $path); if ($preserve_filepath === FALSE) { $name = str_replace($root_path, '', $name); @@ -335,7 +325,7 @@ class CI_Zip { public function get_zip() { // Is there any data to return? - if ($this->entries == 0) + if ($this->entries === 0) { return FALSE; } @@ -392,9 +382,7 @@ class CI_Zip { $CI =& get_instance(); $CI->load->helper('download'); - $get_zip = $this->get_zip(); - $zip_content =& $get_zip; force_download($filename, $zip_content); -- cgit v1.2.3-24-g4f1b From 4f2933d28370ad965059222553d8ace1dd2fe602 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 8 Jan 2012 06:49:49 +0200 Subject: Some more misc. stuff --- system/helpers/array_helper.php | 2 -- system/helpers/captcha_helper.php | 37 +++++++------------------------------ 2 files changed, 7 insertions(+), 32 deletions(-) (limited to 'system') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 881f57db3..a454f936d 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Array Helpers * diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 40b6e5b23..89bff2366 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -67,7 +67,9 @@ if ( ! function_exists('create_captcha')) } } - if ($img_path == '' OR $img_url == '' OR ! @is_dir($img_path) OR ! is_writeable($img_path) OR ! extension_loaded('gd')) + if ($img_path == '' OR $img_url == '' + OR ! @is_dir($img_path) OR ! is_writeable($img_path) + OR ! extension_loaded('gd')) { return FALSE; } @@ -98,11 +100,10 @@ if ( ! function_exists('create_captcha')) if ($word == '') { $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $word = ''; for ($i = 0, $mt_rand_max = strlen($pool) - 1; $i < 8; $i++) { - $word .= substr($pool, mt_rand(0, $mt_rand_max), 1); + $word .= $pool[mt_rand(0, $mt_rand_max)]; } } @@ -110,46 +111,32 @@ if ( ! function_exists('create_captcha')) // ----------------------------------- // Determine angle and position // ----------------------------------- - $length = strlen($word); $angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0; $x_axis = rand(6, (360/$length)-16); $y_axis = ($angle >= 0) ? rand($img_height, $img_width) : rand(6, $img_height); - // ----------------------------------- // Create image - // ----------------------------------- - // PHP.net recommends imagecreatetruecolor(), but it isn't always available - if (function_exists('imagecreatetruecolor')) - { - $im = imagecreatetruecolor($img_width, $img_height); - } - else - { - $im = imagecreate($img_width, $img_height); - } + $im = function_exists('imagecreatetruecolor') + ? imagecreatetruecolor($img_width, $img_height) + : imagecreate($img_width, $img_height); // ----------------------------------- // Assign colors // ----------------------------------- - $bg_color = imagecolorallocate ($im, 255, 255, 255); $border_color = imagecolorallocate ($im, 153, 102, 102); $text_color = imagecolorallocate ($im, 204, 153, 153); $grid_color = imagecolorallocate($im, 255, 182, 182); $shadow_color = imagecolorallocate($im, 255, 240, 240); - // ----------------------------------- // Create the rectangle - // ----------------------------------- - ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color); // ----------------------------------- // Create the spiral pattern // ----------------------------------- - $theta = 1; $thetac = 7; $radius = 16; @@ -173,7 +160,6 @@ if ( ! function_exists('create_captcha')) // ----------------------------------- // Write the text // ----------------------------------- - $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE; if ($use_font == FALSE) @@ -206,29 +192,20 @@ if ( ! function_exists('create_captcha')) } - // ----------------------------------- // Create the border - // ----------------------------------- - imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color); // ----------------------------------- // Generate the image // ----------------------------------- - $img_name = $now.'.jpg'; - ImageJPEG($im, $img_path.$img_name); - $img = "\""; - ImageDestroy($im); return array('word' => $word, 'time' => $now, 'image' => $img); } } -// ------------------------------------------------------------------------ - /* End of file captcha_helper.php */ /* Location: ./system/helpers/captcha_helper.php */ -- cgit v1.2.3-24-g4f1b From e34f1a75ca78825bcf96c4344e01de412f6113bf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 10 Jan 2012 22:41:52 +0200 Subject: Some quotes --- system/libraries/Zip.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 2ed79f0e3..dbcdb2d97 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -112,7 +112,7 @@ class CI_Zip { */ protected function _add_dir($dir, $file_mtime, $file_mdate) { - $dir = str_replace("\\", "/", $dir); + $dir = str_replace('\\', '/', $dir); $this->zipdata .= "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00" @@ -375,7 +375,7 @@ class CI_Zip { */ public function download($filename = 'backup.zip') { - if ( ! preg_match("|.+?\.zip$|", $filename)) + if ( ! preg_match('|.+?\.zip$|', $filename)) { $filename .= '.zip'; } -- cgit v1.2.3-24-g4f1b From 901573ce19e905ce28a3f3345c33dedf9c703cd4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 11 Jan 2012 01:40:48 +0200 Subject: Fix issue 863 --- system/libraries/Form_validation.php | 122 +++++++++++------------------------ 1 file changed, 38 insertions(+), 84 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..78b1ae016 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Form Validation Class * @@ -48,9 +46,6 @@ class CI_Form_validation { protected $error_string = ''; protected $_safe_form_data = FALSE; - /** - * Constructor - */ public function __construct($rules = array()) { $this->CI =& get_instance(); @@ -67,7 +62,7 @@ class CI_Form_validation { mb_internal_encoding($this->CI->config->item('charset')); } - log_message('debug', "Form Validation Class Initialized"); + log_message('debug', 'Form Validation Class Initialized'); } // -------------------------------------------------------------------- @@ -179,7 +174,6 @@ class CI_Form_validation { } $this->_error_messages = array_merge($this->_error_messages, $lang); - return $this; } @@ -198,7 +192,6 @@ class CI_Form_validation { { $this->_error_prefix = $prefix; $this->_error_suffix = $suffix; - return $this; } @@ -313,10 +306,10 @@ class CI_Form_validation { $this->set_rules($this->_config_rules); } - // We're we able to set the rules correctly? + // Were we able to set the rules correctly? if (count($this->_field_data) === 0) { - log_message('debug', "Unable to find validation rules"); + log_message('debug', 'Unable to find validation rules'); return FALSE; } } @@ -330,17 +323,13 @@ class CI_Form_validation { { // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. // Depending on whether the field name is an array or a string will determine where we get it from. - if ($row['is_array'] === TRUE) { $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); } - else + elseif (isset($_POST[$field]) AND $_POST[$field] != '') { - if (isset($_POST[$field]) AND $_POST[$field] != "") - { - $this->_field_data[$field]['postdata'] = $_POST[$field]; - } + $this->_field_data[$field]['postdata'] = $_POST[$field]; } $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); @@ -348,7 +337,6 @@ class CI_Form_validation { // Did we end up with any errors? $total_errors = count($this->_error_array); - if ($total_errors > 0) { $this->_safe_form_data = TRUE; @@ -462,14 +450,12 @@ class CI_Form_validation { return; } - // -------------------------------------------------------------------- - // If the field is blank, but NOT required, no further tests are necessary $callback = FALSE; if ( ! in_array('required', $rules) AND is_null($postdata)) { // Before we bail out, does the rule contain a callback? - if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match)) + if (preg_match('/(callback_\w+(\[.*?\])?)/', implode(' ', $rules), $match)) { $callback = TRUE; $rules = (array('1' => $match[1])); @@ -480,8 +466,6 @@ class CI_Form_validation { } } - // -------------------------------------------------------------------- - // Isset Test. Typically this rule will only apply to checkboxes. if (is_null($postdata) AND $callback === FALSE) { @@ -543,11 +527,9 @@ class CI_Form_validation { $postdata = $this->_field_data[$row['field']]['postdata']; } - // -------------------------------------------------------------------- - // Is the rule a callback? $callback = FALSE; - if (substr($rule, 0, 9) == 'callback_') + if (strpos($rule, 'callback_') === 0) { $rule = substr($rule, 9); $callback = TRUE; @@ -556,7 +538,7 @@ class CI_Form_validation { // Strip the parameter (if exists) from the rule // Rules can contain a parameter: max_length[5] $param = FALSE; - if (preg_match("/(.*?)\[(.*)\]/", $rule, $match)) + if (preg_match('/(.*?)\[(.*)\]/', $rule, $match)) { $rule = $match[1]; $param = $match[2]; @@ -567,11 +549,14 @@ class CI_Form_validation { { if ( ! method_exists($this->CI, $rule)) { - continue; + log_message('debug', 'Unable to find callback validation rule: '.$rule); + $result = FALSE; + } + else + { + // Run the function and grab the result + $result = $this->CI->$rule($postdata, $param); } - - // Run the function and grab the result - $result = $this->CI->$rule($postdata, $param); // Re-assign the result to the master data array if ($_in_array === TRUE) @@ -610,13 +595,14 @@ class CI_Form_validation { } else { - log_message('debug', "Unable to find validation rule: ".$rule); + log_message('debug', 'Unable to find validation rule: '.$rule); + $result = FALSE; } - - continue; } - - $result = $this->$rule($postdata, $param); + else + { + $result = $this->$rule($postdata, $param); + } if ($_in_array === TRUE) { @@ -628,7 +614,7 @@ class CI_Form_validation { } } - // Did the rule test negatively? If so, grab the error. + // Did the rule test negatively? If so, grab the error. if ($result === FALSE) { if ( ! isset($this->_error_messages[$rule])) @@ -644,7 +630,7 @@ class CI_Form_validation { } // Is the parameter we are inserting into the error message the name - // of another field? If so we need to grab its "field label" + // of another field? If so we need to grab its "field label" if (isset($this->_field_data[$param], $this->_field_data[$param]['label'])) { $param = $this->_translate_fieldname($this->_field_data[$param]['label']); @@ -678,7 +664,7 @@ class CI_Form_validation { { // Do we need to translate the field name? // We look for the prefix lang: to determine this - if (substr($fieldname, 0, 5) === 'lang:') + if (strpos($fieldname, 'lang:') === 0) { // Grab the variable $line = substr($fieldname, 5); @@ -738,15 +724,10 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' selected="selected"'; - } - return ''; + return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; - if (is_array($field)) { if ( ! in_array($value, $field)) @@ -754,12 +735,9 @@ class CI_Form_validation { return ''; } } - else + elseif (($field == '' OR $value == '') OR ($field != $value)) { - if (($field == '' OR $value == '') OR ($field != $value)) - { - return ''; - } + return ''; } return ' selected="selected"'; @@ -781,15 +759,10 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' checked="checked"'; - } - return ''; + return ($default === TRUE AND count($this->_field_data) === 0) ? ' checked="checked"' : ''; } $field = $this->_field_data[$field]['postdata']; - if (is_array($field)) { if ( ! in_array($value, $field)) @@ -797,12 +770,9 @@ class CI_Form_validation { return ''; } } - else + elseif (($field == '' OR $value == '') OR ($field != $value)) { - if (($field == '' OR $value == '') OR ($field != $value)) - { - return ''; - } + return ''; } return ' checked="checked"'; @@ -869,9 +839,7 @@ class CI_Form_validation { return FALSE; } - $field = $_POST[$field]; - - return ($str === $field); + return ($str === $_POST[$field]); } // -------------------------------------------------------------------- @@ -908,7 +876,7 @@ class CI_Form_validation { */ public function min_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -932,7 +900,7 @@ class CI_Form_validation { */ public function max_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -956,7 +924,7 @@ class CI_Form_validation { */ public function exact_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -1076,19 +1044,6 @@ class CI_Form_validation { // -------------------------------------------------------------------- - /** - * Is Numeric - * - * @param string - * @return bool - */ - public function is_numeric($str) - { - return is_numeric($str); - } - - // -------------------------------------------------------------------- - /** * Integer * @@ -1217,7 +1172,7 @@ class CI_Form_validation { return $data; } - return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); + return str_replace(array("'", '"', '<', '>'), array(''', '"', '<', '>'), stripslashes($data)); } // -------------------------------------------------------------------- @@ -1230,14 +1185,14 @@ class CI_Form_validation { */ public function prep_url($str = '') { - if ($str == 'http://' OR $str == '') + if ($str === 'http://' OR $str == '') { return ''; } - if (substr($str, 0, 7) !== 'http://' && substr($str, 0, 8) !== 'https://') + if (strpos($str, 'http://') !== 0 && strpos($str, 'https://') !== 0) { - $str = 'http://'.$str; + return 'http://'.$str; } return $str; @@ -1283,7 +1238,6 @@ class CI_Form_validation { } } -// END Form Validation Class /* End of file Form_validation.php */ /* Location: ./system/libraries/Form_validation.php */ -- cgit v1.2.3-24-g4f1b From 8e70b7935181ff56a340a3388080bf4ac6f3428f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 12 Jan 2012 20:19:24 +0200 Subject: CI_Image_lib::image_reproportion() to work if only one of either width or height are set --- system/libraries/Image_lib.php | 195 +++++++++++++++++++---------------------- 1 file changed, 88 insertions(+), 107 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index a226ae8f8..8430d60df 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -88,12 +88,6 @@ class CI_Image_lib { protected $wm_use_drop_shadow = FALSE; public $wm_use_truetype = FALSE; - /** - * Constructor - * - * @param string - * @return void - */ public function __construct($props = array()) { if (count($props) > 0) @@ -101,7 +95,7 @@ class CI_Image_lib { $this->initialize($props); } - log_message('debug', "Image Lib Class Initialized"); + log_message('debug', 'Image Lib Class Initialized'); } // -------------------------------------------------------------------- @@ -158,9 +152,7 @@ class CI_Image_lib { */ public function initialize($props = array()) { - /* - * Convert array elements into class variables - */ + // Convert array elements into class variables if (count($props) > 0) { foreach ($props as $key => $val) @@ -199,7 +191,6 @@ class CI_Image_lib { * Is there a source image? * * If not, there's no reason to continue - * */ if ($this->source_image == '') { @@ -213,7 +204,6 @@ class CI_Image_lib { * We use it to determine the image properties (width/height). * Note: We need to figure out how to determine image * properties using ImageMagick and NetPBM - * */ if ( ! function_exists('getimagesize')) { @@ -229,11 +219,10 @@ class CI_Image_lib { * The source image may or may not contain a path. * Either way, we'll try use realpath to generate the * full server path in order to more reliably read it. - * */ - if (function_exists('realpath') AND @realpath($this->source_image) !== FALSE) + if (function_exists('realpath') && @realpath($this->source_image) !== FALSE) { - $full_source_path = str_replace("\\", "/", realpath($this->source_image)); + $full_source_path = str_replace('\\', '/', realpath($this->source_image)); } else { @@ -257,7 +246,6 @@ class CI_Image_lib { * we are making a copy of the source image. If not * it means we are altering the original. We'll * set the destination filename and path accordingly. - * */ if ($this->new_image == '') { @@ -273,9 +261,9 @@ class CI_Image_lib { } else { - if (function_exists('realpath') AND @realpath($this->new_image) !== FALSE) + if (function_exists('realpath') && @realpath($this->new_image) !== FALSE) { - $full_dest_path = str_replace("\\", "/", realpath($this->new_image)); + $full_dest_path = str_replace('\\', '/', realpath($this->new_image)); } else { @@ -283,7 +271,7 @@ class CI_Image_lib { } // Is there a file name? - if ( ! preg_match("#\.(jpg|jpeg|gif|png)$#i", $full_dest_path)) + if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path)) { $this->dest_folder = $full_dest_path.'/'; $this->dest_image = $this->source_image; @@ -305,7 +293,6 @@ class CI_Image_lib { * full server path to the destination image. * We'll also split the destination image name * so we can insert the thumbnail marker if needed. - * */ if ($this->create_thumb === FALSE OR $this->thumb_marker == '') { @@ -325,10 +312,9 @@ class CI_Image_lib { * * When creating thumbs or copies, the target width/height * might not be in correct proportion with the source - * image's width/height. We'll recalculate it here. - * + * image's width/height. We'll recalculate it here. */ - if ($this->maintain_ratio === TRUE && ($this->width != '' AND $this->height != '')) + if ($this->maintain_ratio === TRUE && ($this->width != 0 OR $this->height != 0)) { $this->image_reproportion(); } @@ -339,35 +325,40 @@ class CI_Image_lib { * If the destination width/height was * not submitted we will use the values * from the actual file - * */ if ($this->width == '') + { $this->width = $this->orig_width; + } if ($this->height == '') + { $this->height = $this->orig_height; + } // Set the quality - $this->quality = trim(str_replace("%", "", $this->quality)); + $this->quality = trim(str_replace('%', '', $this->quality)); - if ($this->quality == '' OR $this->quality == 0 OR ! is_numeric($this->quality)) + if ($this->quality == '' OR $this->quality == 0 OR ! preg_match('/^[0-9]+$/', $this->quality)) + { $this->quality = 90; + } // Set the x/y coordinates - $this->x_axis = ($this->x_axis == '' OR ! is_numeric($this->x_axis)) ? 0 : $this->x_axis; - $this->y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis; + $this->x_axis = ($this->x_axis == '' OR ! preg_match('/^[0-9]+$/', $this->x_axis)) ? 0 : $this->x_axis; + $this->y_axis = ($this->y_axis == '' OR ! preg_match('/^[0-9]+$/', $this->y_axis)) ? 0 : $this->y_axis; // Watermark-related Stuff... if ($this->wm_overlay_path != '') { - $this->wm_overlay_path = str_replace("\\", "/", realpath($this->wm_overlay_path)); + $this->wm_overlay_path = str_replace('\\', '/', realpath($this->wm_overlay_path)); } if ($this->wm_shadow_color != '') { $this->wm_use_drop_shadow = TRUE; } - elseif ($this->wm_use_drop_shadow == TRUE AND $this->wm_shadow_color == '') + elseif ($this->wm_use_drop_shadow == TRUE && $this->wm_shadow_color == '') { $this->wm_use_drop_shadow = FALSE; } @@ -445,7 +436,6 @@ class CI_Image_lib { $this->height = $this->orig_height; } - // Choose resizing function if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm') { @@ -479,9 +469,9 @@ class CI_Image_lib { // If the target width/height match the source, AND if the new file name is not equal to the old file name // we'll simply make a copy of the original with the new name... assuming dynamic rendering is off. - if ($this->dynamic_output === FALSE AND $this->orig_width == $this->width AND $this->orig_height == $this->height) + if ($this->dynamic_output === FALSE && $this->orig_width == $this->width && $this->orig_height == $this->height) { - if ($this->source_image != $this->new_image AND @copy($this->full_src_path, $this->full_dst_path)) + if ($this->source_image != $this->new_image && @copy($this->full_src_path, $this->full_dst_path)) { @chmod($this->full_dst_path, FILE_WRITE_MODE); } @@ -523,7 +513,7 @@ class CI_Image_lib { // below should that ever prove inaccurate. // // if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE) - if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor')) + if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor')) { $create = 'imagecreatetruecolor'; $copy = 'imagecopyresampled'; @@ -587,7 +577,7 @@ class CI_Image_lib { return FALSE; } - if ( ! preg_match("/convert$/i", $this->library_path)) + if ( ! preg_match('/convert$/i', $this->library_path)) { $this->library_path = rtrim($this->library_path, '/').'/convert'; } @@ -597,7 +587,7 @@ class CI_Image_lib { if ($action == 'crop') { - $cmd .= " -crop ".$this->width."x".$this->height."+".$this->x_axis."+".$this->y_axis." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1"; + $cmd .= ' -crop '.$this->width.'x'.$this->height.'+'.$this->x_axis.'+'.$this->y_axis.' "'.$this->full_src_path.'" "'.$this->full_dst_path .'" 2>&1'; } elseif ($action == 'rotate') { @@ -611,18 +601,17 @@ class CI_Image_lib { break; } - $cmd .= " ".$angle." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1"; + $cmd .= ' '.$angle.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; } - else // Resize + else // Resize { - $cmd .= " -resize ".$this->width."x".$this->height." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1"; + $cmd .= ' -resize '.$this->width.'x'.$this->height.'" "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; } $retval = 1; - @exec($cmd, $output, $retval); - // Did it work? + // Did it work? if ($retval > 0) { $this->set_error('imglib_image_process_failed'); @@ -700,10 +689,9 @@ class CI_Image_lib { $cmd = $this->library_path.$cmd_in.' '.$this->full_src_path.' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp'; $retval = 1; - @exec($cmd, $output, $retval); - // Did it work? + // Did it work? if ($retval > 0) { $this->set_error('imglib_image_process_failed'); @@ -742,29 +730,24 @@ class CI_Image_lib { $white = imagecolorallocate($src_img, 255, 255, 255); - // Rotate it! + // Rotate it! $dst_img = imagerotate($src_img, $this->rotation_angle, $white); - // Save the Image + // Show the image if ($this->dynamic_output == TRUE) { $this->image_display_gd($dst_img); } - else + elseif ( ! $this->image_save_gd($dst_img)) // ... or save it { - // Or save it - if ( ! $this->image_save_gd($dst_img)) - { - return FALSE; - } + return FALSE; } - // Kill the file handles + // Kill the file handles imagedestroy($dst_img); imagedestroy($src_img); // Set the file to 777 - @chmod($this->full_dst_path, FILE_WRITE_MODE); return TRUE; @@ -824,21 +807,17 @@ class CI_Image_lib { } } - // Show the image + // Show the image if ($this->dynamic_output == TRUE) { $this->image_display_gd($src_img); } - else + elseif ( ! $this->image_save_gd($src_img)) // ... or save it { - // Or save it - if ( ! $this->image_save_gd($src_img)) - { - return FALSE; - } + return FALSE; } - // Kill the file handles + // Kill the file handles imagedestroy($src_img); // Set the file to 777 @@ -860,14 +839,7 @@ class CI_Image_lib { */ public function watermark() { - if ($this->wm_type == 'overlay') - { - return $this->overlay_watermark(); - } - else - { - return $this->text_watermark(); - } + return ($this->wm_type == 'overlay') ? $this->overlay_watermark() : $this->text_watermark(); } // -------------------------------------------------------------------- @@ -885,28 +857,28 @@ class CI_Image_lib { return FALSE; } - // Fetch source image properties + // Fetch source image properties $this->get_image_properties(); - // Fetch watermark image properties + // Fetch watermark image properties $props = $this->get_image_properties($this->wm_overlay_path, TRUE); $wm_img_type = $props['image_type']; $wm_width = $props['width']; $wm_height = $props['height']; - // Create two image resources + // Create two image resources $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type); $src_img = $this->image_create_gd($this->full_src_path); // Reverse the offset if necessary // When the image is positioned at the bottom // we don't want the vertical offset to push it - // further down. We want the reverse, so we'll - // invert the offset. Same with the horizontal + // further down. We want the reverse, so we'll + // invert the offset. Same with the horizontal // offset when the image is at the right - $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1)); - $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1)); + $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]); + $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]); if ($this->wm_vrt_alignment == 'B') $this->wm_vrt_offset = $this->wm_vrt_offset * -1; @@ -914,11 +886,11 @@ class CI_Image_lib { if ($this->wm_hor_alignment == 'R') $this->wm_hor_offset = $this->wm_hor_offset * -1; - // Set the base x and y axis values + // Set the base x and y axis values $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; - // Set the vertical position + // Set the vertical position switch ($this->wm_vrt_alignment) { case 'T': @@ -929,7 +901,7 @@ class CI_Image_lib { break; } - // Set the horizontal position + // Set the horizontal position switch ($this->wm_hor_alignment) { case 'L': @@ -941,7 +913,7 @@ class CI_Image_lib { } // Build the finalized image - if ($wm_img_type == 3 AND function_exists('imagealphablending')) + if ($wm_img_type == 3 && function_exists('imagealphablending')) { @imagealphablending($src_img, TRUE); } @@ -993,20 +965,20 @@ class CI_Image_lib { return FALSE; } - if ($this->wm_use_truetype == TRUE AND ! file_exists($this->wm_font_path)) + if ($this->wm_use_truetype == TRUE && ! file_exists($this->wm_font_path)) { $this->set_error('imglib_missing_font'); return FALSE; } - // Fetch source image properties + // Fetch source image properties $this->get_image_properties(); // Reverse the vertical offset // When the image is positioned at the bottom // we don't want the vertical offset to push it // further down. We want the reverse, so we'll - // invert the offset. Note: The horizontal + // invert the offset. Note: The horizontal // offset flips itself automatically if ($this->wm_vrt_alignment == 'B') @@ -1093,7 +1065,7 @@ class CI_Image_lib { $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2); $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2])); - // Add the text to the source image + // Add the text to the source image if ($this->wm_use_truetype) { imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); @@ -1106,7 +1078,7 @@ class CI_Image_lib { } } - // Output the final image + // Output the final image if ($this->dynamic_output == TRUE) { $this->image_display_gd($src_img); @@ -1284,33 +1256,43 @@ class CI_Image_lib { */ public function image_reproportion() { - if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0) - return; - - if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0) - return; - - $new_width = ceil($this->orig_width*$this->height/$this->orig_height); - $new_height = ceil($this->width*$this->orig_height/$this->orig_width); - - $ratio = (($this->orig_height/$this->orig_width) - ($this->height/$this->width)); - - if ($this->master_dim != 'width' AND $this->master_dim != 'height') + if (($this->width == 0 && $this->height == 0) OR $this->orig_width == 0 OR $this->orig_height == 0 + OR ( ! preg_match('/^[0-9]+$/', $this->width) && ! preg_match('/^[0-9]+$/', $this->height)) + OR ! preg_match('/^[0-9]+$/', $this->orig_width) OR ! preg_match('/^[0-9]+$/', $this->orig_height)) { - $this->master_dim = ($ratio < 0) ? 'width' : 'height'; + return; } - if (($this->width != $new_width) AND ($this->height != $new_height)) + // Sanitize so we don't call preg_match() anymore + $this->width = (int) $this->width; + $this->height = (int) $this->height; + + if ($this->master_dim !== 'width' && $this->master_dim !== 'height') { - if ($this->master_dim == 'height') + if ($this->width > 0 && $this->height > 0) { - $this->width = $new_width; + $this->master_dim = ((($this->orig_height/$this->orig_width) - ($this->height/$this->width)) < 0) + ? 'width' : 'height'; } else { - $this->height = $new_height; + $this->master_dim = ($this->height === 0) ? 'width' : 'height'; } } + elseif (($this->master_dim === 'width' && $this->width === 0) + OR ($this->master_dim === 'height' && $this->height === 0)) + { + return; + } + + if ($this->master_dim === 'width') + { + $this->height = (int) ceil($this->width*$this->orig_height/$this->orig_width); + } + else + { + $this->width = (int) ceil($this->orig_width*$this->height/$this->orig_height); + } } // -------------------------------------------------------------------- @@ -1329,7 +1311,9 @@ class CI_Image_lib { // find a way to determine this using IM or NetPBM if ($path == '') + { $path = $this->full_src_path; + } if ( ! file_exists($path)) { @@ -1449,7 +1433,7 @@ class CI_Image_lib { /* As it is stated in the PHP manual, dl() is not always available * and even if so - it could generate an E_WARNING message on failure */ - return (function_exists('dl') AND @dl('gd.so')); + return (function_exists('dl') && @dl('gd.so')); } return TRUE; @@ -1467,9 +1451,7 @@ class CI_Image_lib { if (function_exists('gd_info')) { $gd_version = @gd_info(); - $gd_version = preg_replace("/\D/", "", $gd_version['GD Version']); - - return $gd_version; + return preg_replace('/\D/', '', $gd_version['GD Version']); } return FALSE; @@ -1520,7 +1502,6 @@ class CI_Image_lib { } } -// END Image_lib Class /* End of file Image_lib.php */ /* Location: ./system/libraries/Image_lib.php */ -- cgit v1.2.3-24-g4f1b From e46363083ad18c93c73a200c9a97934608bb5bab Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 12 Jan 2012 20:23:27 +0200 Subject: Remove a quote --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 8430d60df..fd3cd0edb 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -605,7 +605,7 @@ class CI_Image_lib { } else // Resize { - $cmd .= ' -resize '.$this->width.'x'.$this->height.'" "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; + $cmd .= ' -resize '.$this->width.'x'.$this->height.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; } $retval = 1; -- cgit v1.2.3-24-g4f1b From cde43687ef19aa23ee6796925270961b760369f3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Jan 2012 20:16:35 +0200 Subject: Allow native PHP functions used as rules to accept an additional parameter --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 78b1ae016..9aa07a1a8 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -582,7 +582,7 @@ class CI_Form_validation { // Users can use any native PHP function call that has one param. if (function_exists($rule)) { - $result = $rule($postdata); + $result = ($param !== FALSE) ? $rule($postdata, $param) : $rule($postdata); if ($_in_array === TRUE) { -- cgit v1.2.3-24-g4f1b From aa786c93e48f3081da9aa6d9d13e5857565a1070 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 16 Jan 2012 12:14:45 +0200 Subject: Additional clean-up --- system/database/drivers/oci8/oci8_driver.php | 188 +++++++++++--------------- system/database/drivers/oci8/oci8_forge.php | 86 +++--------- system/database/drivers/oci8/oci8_result.php | 71 +++------- system/database/drivers/oci8/oci8_utility.php | 4 +- 4 files changed, 123 insertions(+), 226 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index f520f7c76..2a5149f9e 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * oci8 Database Adapter Class * @@ -84,7 +82,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Non-persistent database connection * - * @return resource + * @return resource */ public function db_connect() { @@ -96,7 +94,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Persistent database connection * - * @return resource + * @return resource */ public function db_pconnect() { @@ -124,7 +122,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Select the database * - * @return resource + * @return resource */ public function db_select() { @@ -152,7 +150,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Version number query string * - * @return string + * @return string */ protected function _version() { @@ -164,8 +162,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * Execute the query * - * @param string an SQL query - * @return resource + * @param string an SQL query + * @return resource */ protected function _execute($sql) { @@ -181,8 +179,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * Generate a statement ID * - * @param string an SQL query - * @return none + * @param string an SQL query + * @return void */ private function _set_stmt_id($sql) { @@ -199,8 +197,8 @@ class CI_DB_oci8_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @param string an SQL query - * @return string + * @param string an SQL query + * @return string */ private function _prep_query($sql) { @@ -210,14 +208,13 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- /** - * getCursor. Returns a cursor from the datbase + * getCursor. Returns a cursor from the database * - * @return cursor id + * @return resource cursor id */ public function get_cursor() { - $this->curs_id = oci_new_cursor($this->conn_id); - return $this->curs_id; + return $this->curs_id = oci_new_cursor($this->conn_id); } // -------------------------------------------------------------------- @@ -225,19 +222,19 @@ class CI_DB_oci8_driver extends CI_DB { /** * Stored Procedure. Executes a stored procedure * - * @param package package stored procedure is in - * @param procedure stored procedure to execute - * @param params array of parameters - * @return array + * @param string package name in which the stored procedure is in + * @param string stored procedure name to execute + * @param array parameters + * @return mixed * * params array keys * * KEY OPTIONAL NOTES - * name no the name of the parameter should be in : format - * value no the value of the parameter. If this is an OUT or IN OUT parameter, - * this should be a reference to a variable - * type yes the type of the parameter - * length yes the max size of the parameter + * name no the name of the parameter should be in : format + * value no the value of the parameter. If this is an OUT or IN OUT parameter, + * this should be a reference to a variable + * type yes the type of the parameter + * length yes the max size of the parameter */ public function stored_procedure($package, $procedure, $params) { @@ -252,24 +249,24 @@ class CI_DB_oci8_driver extends CI_DB { } // build the query string - $sql = "begin $package.$procedure("; + $sql = "BEGIN {$package}.{$procedure}("; $have_cursor = FALSE; foreach ($params as $param) { - $sql .= $param['name'] . ","; + $sql .= $param['name'].','; if (array_key_exists('type', $param) && ($param['type'] === OCI_B_CURSOR)) { $have_cursor = TRUE; } } - $sql = trim($sql, ",") . "); end;"; + $sql = trim($sql, ',') . '); END;'; $this->stmt_id = FALSE; $this->_set_stmt_id($sql); $this->_bind_params($params); - $this->query($sql, FALSE, $have_cursor); + return $this->query($sql, FALSE, $have_cursor); } // -------------------------------------------------------------------- @@ -277,7 +274,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Bind parameters * - * @return none + * @return void */ private function _bind_params($params) { @@ -382,9 +379,9 @@ class CI_DB_oci8_driver extends CI_DB { /** * Escape String * - * @param string + * @param string * @param bool whether or not the string will be used in a LIKE condition - * @return string + * @return string */ public function escape_str($str, $like = FALSE) { @@ -398,15 +395,14 @@ class CI_DB_oci8_driver extends CI_DB { return $str; } - $str = remove_invisible_characters($str); - $str = str_replace("'", "''", $str); + $str = str_replace("'", "''", remove_invisible_characters($str)); // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), - $str); + return str_replace(array('%', '_', $this->_like_escape_chr), + array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), + $str); } return $str; @@ -417,7 +413,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Affected Rows * - * @return integer + * @return int */ public function affected_rows() { @@ -429,7 +425,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Insert ID * - * @return integer + * @return int */ public function insert_id() { @@ -445,8 +441,8 @@ class CI_DB_oci8_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @param string - * @return string + * @param string + * @return int */ public function count_all($table = '') { @@ -455,7 +451,7 @@ class CI_DB_oci8_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query($this->_count_string.$this->_protect_identifiers('numrows').' FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); if ($query == FALSE) { @@ -474,16 +470,16 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @param boolean + * @param bool * @return string */ protected function _list_tables($prefix_limit = FALSE) { - $sql = "SELECT TABLE_NAME FROM ALL_TABLES"; + $sql = 'SELECT TABLE_NAME FROM ALL_TABLES'; if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - $sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); + return $sql." WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } return $sql; @@ -496,12 +492,12 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @param string the table name - * @return string + * @param string the table name + * @return string */ protected function _list_columns($table = '') { - return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'"; + return 'SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = \''.$table.'\''; } // -------------------------------------------------------------------- @@ -511,12 +507,12 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @param string the table name - * @return object + * @param string the table name + * @return string */ protected function _field_data($table) { - return "SELECT * FROM ".$table." where rownum = 1"; + return 'SELECT * FROM '.$table.' WHERE rownum = 1'; } // -------------------------------------------------------------------- @@ -524,7 +520,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message string * - * @return string + * @return string */ protected function _error_message() { @@ -537,7 +533,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message number * - * @return integer + * @return int */ protected function _error_number() { @@ -589,24 +585,20 @@ class CI_DB_oci8_driver extends CI_DB { { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + $item = str_replace('.', $this->_escape_char.'.', $item); // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item); } } if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; - } - else - { - $str = $this->_escape_char.$item.$this->_escape_char; + $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item); } // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char); } // -------------------------------------------------------------------- @@ -617,8 +609,8 @@ class CI_DB_oci8_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @param type - * @return type + * @param array + * @return string */ protected function _from_tables($tables) { @@ -637,14 +629,14 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ protected function _insert($table, $keys, $values) { - return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } // -------------------------------------------------------------------- @@ -666,12 +658,10 @@ class CI_DB_oci8_driver extends CI_DB { for ($i = 0, $c = count($values); $i < $c; $i++) { - $sql .= ' INTO ' . $table . ' (' . $keys . ') VALUES ' . $values[$i] . "\n"; + $sql .= ' INTO '.$table.' ('.$keys.') VALUES '.$values[$i].'\n'; } - $sql .= 'SELECT * FROM dual'; - - return $sql; + return $sql.'SELECT * FROM dual'; } // -------------------------------------------------------------------- @@ -692,18 +682,13 @@ class CI_DB_oci8_driver extends CI_DB { { foreach ($values as $key => $val) { - $valstr[] = $key." = ".$val; + $valstr[] = $key.' = '.$val; } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - - $orderby = (count($orderby) > 0) ? ' ORDER BY '.implode(', ', $orderby) : ''; - - $sql = 'UPDATE '.$table.' SET '.implode(', ', $valstr); - $sql .= ($where != '' AND count($where) > 0) ? ' WHERE '.implode(' ', $where) : ''; - $sql .= $orderby.$limit; - - return $sql; + return 'UPDATE '.$table.' SET '.implode(', ', $valstr) + .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '') + .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '') + .( ! $limit ? '' : ' LIMIT '.$limit); } // -------------------------------------------------------------------- @@ -720,7 +705,7 @@ class CI_DB_oci8_driver extends CI_DB { */ protected function _truncate($table) { - return "TRUNCATE TABLE ".$table; + return 'TRUNCATE TABLE '.$table; } // -------------------------------------------------------------------- @@ -738,22 +723,18 @@ class CI_DB_oci8_driver extends CI_DB { protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; - if (count($where) > 0 OR count($like) > 0) { - $conditions = "\nWHERE "; - $conditions .= implode("\n", $this->ar_where); + $conditions = "\nWHERE ".implode("\n", $this->ar_where); if (count($where) > 0 && count($like) > 0) { - $conditions .= " AND "; + $conditions .= ' AND '; } $conditions .= implode("\n", $like); } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - - return "DELETE FROM ".$table.$conditions.$limit; + return 'DELETE FROM '.$table.$conditions.( ! $limit ? '' : ' LIMIT '.$limit); } // -------------------------------------------------------------------- @@ -763,25 +744,16 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value - * @return string + * @param string the sql query string + * @param int the number of rows to limit the query to + * @param int the offset value + * @return string */ protected function _limit($sql, $limit, $offset) { - $limit = $offset + $limit; - $newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)"; - - if ($offset != 0) - { - $newsql .= " WHERE rnum >= $offset"; - } - - // remember that we used limits $this->limit_used = TRUE; - - return $newsql; + return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($offset + $limit).')' + .($offset != 0 ? ' WHERE rnum >= '.$offset : ''); } // -------------------------------------------------------------------- @@ -789,8 +761,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * Close DB Connection * - * @param resource - * @return void + * @param resource + * @return void */ protected function _close($conn_id) { diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 6975f2a5f..6b9a8e8fd 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Oracle Forge Class * @@ -71,7 +69,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param array the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @param bool should 'IF NOT EXISTS' be added to the SQL * @return string */ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) @@ -83,7 +81,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { $sql .= 'IF NOT EXISTS '; } - $sql .= $this->db->_escape_identifiers($table)." ("; + $sql .= $this->db->_escape_identifiers($table).' ('; $current_field_count = 0; foreach ($fields as $field=>$attributes) @@ -93,37 +91,17 @@ class CI_DB_oci8_forge extends CI_DB_forge { // entered the field information, so we'll simply add it to the list if (is_numeric($field)) { - $sql .= "\n\t$attributes"; + $sql .= "\n\t".$attributes; } else { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field).' '.$attributes['TYPE']; - - if (array_key_exists('CONSTRAINT', $attributes)) - { - $sql .= '('.$attributes['CONSTRAINT'].')'; - } - - if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) - { - $sql .= ' UNSIGNED'; - } - - if (array_key_exists('DEFAULT', $attributes)) - { - $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; - } - - if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) - { - $sql .= ' NULL'; - } - else - { - $sql .= ' NOT NULL'; - } + $sql .= "\n\t".$this->db->_protect_identifiers($field).' '.$attributes['TYPE'] + .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '') + .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') + .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') + .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL'); } // don't add a comma on the end of the last field @@ -136,7 +114,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { if (count($primary_keys) > 0) { $primary_keys = $this->db->_protect_identifiers($primary_keys); - $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; + $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')'; } if (is_array($keys) && count($keys) > 0) @@ -152,13 +130,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { $key = array($this->db->_protect_identifiers($key)); } - $sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")"; + $sql .= ",\n\tUNIQUE COLUMNS (".implode(', ', $key).')'; } } - $sql .= "\n)"; - - return $sql; + return $sql."\n)"; } // -------------------------------------------------------------------- @@ -170,7 +146,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ public function _drop_table($table) { - return 'DROP TABLE ' . $this->db->_protect_identifiers($table); + return 'DROP TABLE '.$this->db->_protect_identifiers($table); } // -------------------------------------------------------------------- @@ -186,42 +162,24 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the table name * @param string the column definition * @param string the default value - * @param boolean should 'NOT NULL' be added + * @param bool should 'NOT NULL' be added * @param string the field after which we should add the new field * @return string */ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table).' '.$alter_type.' '.$this->db->_protect_identifiers($column_name); // DROP has everything it needs now. - if ($alter_type == 'DROP') + if ($alter_type === 'DROP') { return $sql; } - $sql .= " $column_definition"; - - if ($default_value != '') - { - $sql .= " DEFAULT \"$default_value\""; - } - - if ($null === NULL) - { - $sql .= ' NULL'; - } - else - { - $sql .= ' NOT NULL'; - } - - if ($after_field != '') - { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); - } - - return $sql; + return $sql.' '.$column_definition + .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '') + .($null === NULL ? ' NULL' : ' NOT NULL') + .($after_field != '' ? ' AFTER '.$this->db->_protect_identifiers($after_field) : ''); } @@ -238,11 +196,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ public function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); } - } /* End of file oci8_forge.php */ diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index cbf4bec52..fad2465df 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * oci8 Result Class * @@ -56,7 +54,7 @@ class CI_DB_oci8_result extends CI_DB_result { * Oracle doesn't have a graceful way to return the number of rows * so we have to use what amounts to a hack. * - * @return integer + * @return int */ public function num_rows() { @@ -82,19 +80,14 @@ class CI_DB_oci8_result extends CI_DB_result { /** * Number of fields in the result set * - * @return integer + * @return int */ public function num_fields() { $count = @oci_num_fields($this->stmt_id); // if we used a limit we subtract it - if ($this->limit_used) - { - return $count - 1; - } - - return $count; + return ($this->limit_used) ? $count - 1 : $count; } // -------------------------------------------------------------------- @@ -123,17 +116,17 @@ class CI_DB_oci8_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @return array + * @return array */ public function field_data() { $retval = array(); for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++) { - $F = new stdClass(); - $F->name = oci_field_name($this->stmt_id, $c); - $F->type = oci_field_type($this->stmt_id, $c); - $F->max_length = oci_field_size($this->stmt_id, $c); + $F = new stdClass(); + $F->name = oci_field_name($this->stmt_id, $c); + $F->type = oci_field_type($this->stmt_id, $c); + $F->max_length = oci_field_size($this->stmt_id, $c); $retval[] = $F; } @@ -175,7 +168,7 @@ class CI_DB_oci8_result extends CI_DB_result { * * Returns the result set as an array * - * @return array + * @return array */ protected function _fetch_assoc() { @@ -190,7 +183,7 @@ class CI_DB_oci8_result extends CI_DB_result { * * Returns the result set as an object * - * @return object + * @return object */ protected function _fetch_object() { @@ -200,33 +193,6 @@ class CI_DB_oci8_result extends CI_DB_result { // -------------------------------------------------------------------- - /* Query result - * - * Acts as a wrapper for result_array(), result_object() - * and custom_result_object(). - * - * @param string ('object', 'array' or a custom class name) - * @return array - */ - - public function result($type = 'object') - { - if ($type === 'object') - { - return $this->result_object(); - } - elseif ($type === 'array') - { - return $this->result_array(); - } - else - { - return $this->custom_result_object($type); - } - } - - // -------------------------------------------------------------------- - /** * Query result. "array" version. * @@ -452,9 +418,16 @@ class CI_DB_oci8_result extends CI_DB_result { public function row($n = 0, $type = 'object') { - if ($type === 'object') return $this->row_object($n); - elseif ($type === 'array') return $this->row_array($n); - else return $this->custom_row_object($n, $type); + if ($type === 'object') + { + return $this->row_object($n); + } + elseif ($type === 'array') + { + return $this->row_array($n); + } + + return $this->custom_row_object($n, $type); } // -------------------------------------------------------------------- @@ -464,7 +437,6 @@ class CI_DB_oci8_result extends CI_DB_result { * @param int row index * @return array */ - public function row_array($n = 0) { // Make sure $n is not a string @@ -656,7 +628,6 @@ class CI_DB_oci8_result extends CI_DB_result { * @param string ('object', 'array' or a custom class name) * @return mixed whatever was passed to the second parameter */ - public function first_row($type = 'object') { return $this->row(0, $type); diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index 317ff91eb..38d870aa6 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Oracle Utility Class * -- cgit v1.2.3-24-g4f1b From 8ae24c57a1240a5a5e3fbd5755227e5d42b75390 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 16 Jan 2012 13:05:23 +0200 Subject: Add SQLite3 database driver --- system/database/DB_driver.php | 2 +- system/database/drivers/sqlite3/index.html | 10 + system/database/drivers/sqlite3/sqlite3_driver.php | 591 ++++++++++++++++++++ system/database/drivers/sqlite3/sqlite3_forge.php | 223 ++++++++ system/database/drivers/sqlite3/sqlite3_result.php | 617 +++++++++++++++++++++ .../database/drivers/sqlite3/sqlite3_utility.php | 102 ++++ 6 files changed, 1544 insertions(+), 1 deletion(-) create mode 100644 system/database/drivers/sqlite3/index.html create mode 100644 system/database/drivers/sqlite3/sqlite3_driver.php create mode 100644 system/database/drivers/sqlite3/sqlite3_forge.php create mode 100644 system/database/drivers/sqlite3/sqlite3_result.php create mode 100644 system/database/drivers/sqlite3/sqlite3_utility.php (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 661b42ced..43c201ef6 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -257,7 +257,7 @@ class CI_DB_driver { // Some DBs have functions that return the version, and don't run special // SQL queries per se. In these instances, just return the result. - $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo'); + $driver_version_exceptions = array('oci8', 'sqlite', 'sqlite3', 'cubrid', 'pdo'); if (in_array($this->dbdriver, $driver_version_exceptions)) { diff --git a/system/database/drivers/sqlite3/index.html b/system/database/drivers/sqlite3/index.html new file mode 100644 index 000000000..c942a79ce --- /dev/null +++ b/system/database/drivers/sqlite3/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php new file mode 100644 index 000000000..b82ae1ecd --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -0,0 +1,591 @@ +password) + ? new SQLite3($this->database) + : new SQLite3($this->database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $this->password); + } + catch (Exception $e) + { + return FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Persistent database connection + * + * @return object type SQLite3 + */ + public function db_pconnect() + { + log_message('debug', 'SQLite3 doesn\'t support persistent connections'); + return $this->db_pconnect(); + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @return void + */ + public function reconnect() + { + // Not supported + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @return bool + */ + public function db_select() + { + // Not needed, in SQLite every pseudo-connection is a database + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @param string + * @param string + * @return bool + */ + public function db_set_charset($charset, $collation) + { + // Not (natively) supported + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @return string + */ + protected function _version() + { + return implode(' (', $this->conn_id->version()).')'; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string an SQL query + * @return mixed SQLite3Result object or bool + */ + protected function _execute($sql) + { + if ( ! preg_match('/^(SELECT|EXPLAIN).+$/i', ltrim($sql))) + { + return $this->conn_id->exec($sql); + } + + // TODO: Implement use of SQLite3::querySingle(), if needed + // TODO: Use $this->_prep_query(), if needed + return $this->conn_id->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Prep the query + * + * If needed, each database adapter can prep the query string + * + * @param string an SQL query + * @return string + */ + private function _prep_query($sql) + { + return $this->conn_id->prepare($sql); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE); + + return $this->conn_id->exec('BEGIN TRANSACTION'); + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + return $this->conn_id->exec('END TRANSACTION'); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + return $this->conn_id->exec('ROLLBACK'); + } + + // -------------------------------------------------------------------- + + /** + * Escape String + * + * @param string + * @param bool whether or not the string will be used in a LIKE condition + * @return string + */ + public function escape_str($str, $like = FALSE) + { + if (is_array($str)) + { + foreach ($str as $key => $val) + { + $str[$key] = $this->escape_str($val, $like); + } + + return $str; + } + + $str = $this->conn_id->escapeString(remove_invisible_characters($str)); + + // escape LIKE condition wildcards + if ($like === TRUE) + { + return str_replace(array('%', '_', $this->_like_escape_chr), + array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), + $str); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return $this->conn_id->changes(); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return int + */ + public function insert_id() + { + return $this->conn_id->lastInsertRowID(); + } + + // -------------------------------------------------------------------- + + /** + * "Count All" query + * + * Generates a platform-specific query string that counts all records in + * the specified database + * + * @param string + * @return int + */ + public function count_all($table = '') + { + if ($table == '') + { + return 0; + } + + $result = $this->conn_id->querySingle($this->_count_string.$this->_protect_identifiers('numrows') + .' FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); + + return empty($result) ? 0 : (int) $result; + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + return 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\'' + .(($prefix_limit !== FALSE && $this->dbprefix != '') + ? ' AND "NAME" LIKE \''.$this->escape_like_str($this->dbprefix).'%\' '.sprintf($this->_like_escape_str, $this->_like_escape_chr) + : ''); + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string the table name + * @return string + */ + protected function _list_columns($table = '') + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Field data query + * + * Generates a platform-specific query so that the column data can be retrieved + * + * @param string the table name + * @return string + */ + protected function _field_data($table) + { + return 'SELECT * FROM '.$table.' LIMIT 0,1'; + } + + // -------------------------------------------------------------------- + + /** + * The error message string + * + * @return string + */ + protected function _error_message() + { + return $this->conn_id->lastErrorMsg(); + } + + // -------------------------------------------------------------------- + + /** + * The error message number + * + * @return int + */ + protected function _error_number() + { + return $this->conn_id->lastErrorCode(); + } + + // -------------------------------------------------------------------- + + /** + * Escape the SQL Identifiers + * + * This function escapes column and table names + * + * @param string + * @return string + */ + protected function _escape_identifiers($item) + { + if ($this->_escape_char == '') + { + return $item; + } + + foreach ($this->_reserved_identifiers as $id) + { + if (strpos($item, '.'.$id) !== FALSE) + { + $item = str_replace('.', $this->_escape_char.'.', $item); + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item); + } + } + + if (strpos($item, '.') !== FALSE) + { + $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item); + } + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char); + } + + // -------------------------------------------------------------------- + + /** + * From Tables + * + * This function implicitly groups FROM tables so there is no confusion + * about operator precedence in harmony with SQL standards + * + * @param string + * @return string + */ + protected function _from_tables($tables) + { + if ( ! is_array($tables)) + { + $tables = array($tables); + } + + return '('.implode(', ', $tables).')'; + } + + // -------------------------------------------------------------------- + + /** + * Insert statement + * + * Generates a platform-specific insert string from the supplied data + * + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + protected function _insert($table, $keys, $values) + { + return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string the table name + * @param array the update data + * @param array the where clause + * @param array the orderby clause + * @param array the limit clause + * @return string + */ + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + { + foreach ($values as $key => $val) + { + $valstr[] = $key.' = '.$val; + } + + return 'UPDATE '.$table.' SET '.implode(', ', $valstr) + .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '') + .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '') + .( ! $limit ? '' : ' LIMIT '.$limit); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * If the database does not support the truncate() command, then + * this method maps to "DELETE FROM table" + * + * @param string the table name + * @return string + */ + protected function _truncate($table) + { + return $this->_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string the table name + * @param array the where clause + * @param string the limit clause + * @return string + */ + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) + { + $conditions = ''; + if (count($where) > 0 OR count($like) > 0) + { + $conditions .= "\nWHERE ".implode("\n", $this->ar_where); + + if (count($where) > 0 && count($like) > 0) + { + $conditions .= ' AND '; + } + $conditions .= implode("\n", $like); + } + + return 'DELETE FROM '.$table.$conditions.( ! $limit ? '' : ' LIMIT '.$limit); + } + + // -------------------------------------------------------------------- + + /** + * Limit string + * + * Generates a platform-specific LIMIT clause + * + * @param string the sql query string + * @param int the number of rows to limit the query to + * @param int the offset value + * @return string + */ + protected function _limit($sql, $limit, $offset) + { + return $sql.($offset ? $offset.',' : '').$limit; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + $this->conn_id->close(); + } + +} + +/* End of file sqlite3_driver.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_driver.php */ diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php new file mode 100644 index 000000000..07c25515a --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -0,0 +1,223 @@ +db->database)) + { + // We need to close the pseudo-connection first + $this->db->close(); + if ( ! @unlink($this->db->database)) + { + return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + return TRUE; + } + + return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Create Table + * + * @param string the table name + * @param array the fields + * @param mixed primary key(s) + * @param mixed key(s) + * @param bool should 'IF NOT EXISTS' be added to the SQL + * @return bool + */ + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + { + $sql = 'CREATE TABLE '; + + // IF NOT EXISTS added to SQLite in 3.3.0 + if ($if_not_exists === TRUE && version_compare($this->db->version(), '3.3.0', '>=') === TRUE) + { + $sql .= 'IF NOT EXISTS '; + } + + $sql .= $this->db->_escape_identifiers($table).'('; + $current_field_count = 0; + + foreach ($fields as $field=>$attributes) + { + // Numeric field names aren't allowed in databases, so if the key is + // numeric, we know it was assigned by PHP and the developer manually + // entered the field information, so we'll simply add it to the list + if (is_numeric($field)) + { + $sql .= "\n\t".$attributes; + } + else + { + $attributes = array_change_key_case($attributes, CASE_UPPER); + + $sql .= "\n\t".$this->db->_protect_identifiers($field) + .' '.$attributes['TYPE'] + .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '') + .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') + .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') + .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') + .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : ''); + } + + // don't add a comma on the end of the last field + if (++$current_field_count < count($fields)) + { + $sql .= ','; + } + } + + if (count($primary_keys) > 0) + { + $primary_keys = $this->db->_protect_identifiers($primary_keys); + $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')'; + } + + if (is_array($keys) && count($keys) > 0) + { + foreach ($keys as $key) + { + if (is_array($key)) + { + $key = $this->db->_protect_identifiers($key); + } + else + { + $key = array($this->db->_protect_identifiers($key)); + } + + $sql .= ",\n\tUNIQUE (".implode(', ', $key).')'; + } + } + + return $sql."\n)"; + } + + // -------------------------------------------------------------------- + + /** + * Drop Table + * + * @param string the table name + * @return string + */ + public function _drop_table($table) + { + return 'DROP TABLE '.$table.' IF EXISTS'; + } + + // -------------------------------------------------------------------- + + /** + * Alter table query + * + * Generates a platform-specific query so that a table can be altered + * Called by add_column(), drop_column(), and column_alter(), + * + * @param string the ALTER type (ADD, DROP, CHANGE) + * @param string the column name + * @param string the table name + * @param string the column definition + * @param string the default value + * @param bool should 'NOT NULL' be added + * @param string the field after which we should add the new field + * @return string + */ + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + { + /* SQLite only supports adding new columns and it does + * NOT support the AFTER statement. Each new column will + * be added as the last one in the table. + */ + if ($alter_type !== 'ADD COLUMN') + { + // Not supported + return FALSE; + } + + return 'ALTER TABLE '.$this->db->_protect_identifiers($table).' '.$alter_type.' '.$this->db->_protect_identifiers($column_name) + .' '.$column_definition + .($default_value != '' ? ' DEFAULT '.$default_value : '') + // If NOT NULL is specified, the field must have a DEFAULT value other than NULL + .(($null !== NULL && $default_value !== 'NULL') ? ' NOT NULL' : ' NULL'); + } + + // -------------------------------------------------------------------- + + /** + * Rename a table + * + * Generates a platform-specific query so that a table can be renamed + * + * @param string the old table name + * @param string the new table name + * @return string + */ + public function _rename_table($table_name, $new_table_name) + { + return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); + } +} + +/* End of file sqlite3_forge.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_forge.php */ diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php new file mode 100644 index 000000000..7b1b4502a --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -0,0 +1,617 @@ +num_rows) + ? $this->num_rows + : $this->num_rows = count($this->result_array()); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return ( ! is_int($this->_num_fields)) + ? $this->_num_fields = $this->result_id->numColumns() + : $this->_num_fields; + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + for ($i = 0, $c = $this->num_fields(); $i < $this->num_fields(); $i++) + { + $field_names[] = $this->result_id->columnName($i); + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($i = 0, $c = $this->num_fields(); $i < $this->num_fields(); $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $this->result_id->columnName($i); + $retval[$i]->type = 'varchar'; + $retval[$i]->max_length = 0; + $retval[$i]->primary_key = 0; + $retval[$i]->default = ''; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_object($this->result_id)) + { + $this->result_id->finalize(); + $this->result_id = NULL; + } + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return $this->result_id->fetchArray(SQLITE3_ASSOC); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @access private + * @return object + */ + protected function _fetch_object() + { + // No native support for fetching as an object + $row = $this->_fetch_assoc(); + return ($row !== FALSE) ? (object) $row : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Query result. "array" version. + * + * return array + */ + public function result_array() + { + if (count($this->result_array) > 0) + { + return $this->result_array; + } + elseif (is_array($this->row_data)) + { + if (count($this->row_data) === 0) + { + return $this->result_array; + } + else + { + $row_index = count($this->row_data); + } + } + else + { + $row_index = 0; + $this->row_data = array(); + } + + $row = NULL; + while ($row = $this->_fetch_assoc()) + { + $this->row_data[$row_index++] = $row; + } + + // Un-comment the following line, in case it becomes needed + // $this->_data_seek(); + return $this->result_array = $this->row_data; + } + + // -------------------------------------------------------------------- + + /** + * Query result. "object" version. + * + * @return array + */ + public function result_object() + { + if (count($this->result_object) > 0) + { + return $this->result_object; + } + elseif (count($this->result_array) > 0) + { + for ($i = 0, $c = count($this->result_array); $i < $c; $i++) + { + $this->result_object[] = (object) $this->result_array[$i]; + } + + return $this->result_object; + } + elseif (is_array($this->row_data)) + { + if (count($this->row_data) === 0) + { + return $this->result_object; + } + else + { + $row_index = count($this->row_data); + for ($i = 0; $i < $row_index; $i++) + { + $this->result_object[$i] = (object) $this->row_data[$i]; + } + } + } + else + { + $row_index = 0; + $this->row_data = array(); + } + + $row = NULL; + while ($row = $this->_fetch_assoc()) + { + $this->row_data[$row_index] = $row; + $this->result_object[$row_index++] = (object) $row; + } + + $this->result_array = $this->row_data; + + /* As described for the num_rows() method - there's no easy + * way to get the number of rows selected. Our work-around + * solution (as in here as well) first checks if result_array + * exists and returns its count. It doesn't however check for + * custom_object_result, so - do it here. + */ + if ( ! is_int($this->num_rows)) + { + $this->num_rows = count($this->result_object); + } + + // Un-comment the following line, in case it becomes needed + // $this->_data_seek(); + return $this->result_object; + } + + // -------------------------------------------------------------------- + + /** + * Query result. Custom object version. + * + * @param string class name used to instantiate rows to + * @return array + */ + public function custom_result_object($class_name) + { + if (array_key_exists($class_name, $this->custom_result_object)) + { + return $this->custom_result_object[$class_name]; + } + + if ( ! class_exists($class_name) OR ! is_object($this->result_id) OR $this->num_rows() === 0) + { + return array(); + } + + /* Even if result_array hasn't been set prior to custom_result_object being called, + * num_rows() has done it. + */ + $data = &$this->result_array; + + $result_object = array(); + for ($i = 0, $c = count($data); $i < $c; $i++) + { + $result_object[$i] = new $class_name(); + foreach ($data[$i] as $key => $value) + { + $result_object[$i]->$key = $value; + } + } + + /* As described for the num_rows() method - there's no easy + * way to get the number of rows selected. Our work-around + * solution (as in here as well) first checks if result_array + * exists and returns its count. It doesn't however check for + * custom_object_result, so - do it here. + */ + if ( ! is_int($this->num_rows)) + { + $this->num_rows = count($result_object); + } + + // Cache and return the array + return $this->custom_result_object[$class_name] = $result_object; + } + + // -------------------------------------------------------------------- + + /* Single row result. + * + * Acts as a wrapper for row_object(), row_array() + * and custom_row_object(). Also used by first_row(), next_row() + * and previous_row(). + * + * @param int row index + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function row($n = 0, $type = 'object') + { + if ($type === 'object') + { + return $this->row_object($n); + } + elseif ($type === 'array') + { + return $this->row_array($n); + } + + return $this->custom_row_object($n, $type); + } + + // -------------------------------------------------------------------- + + /* Single row result. Array version. + * + * @param int row index + * @return array + */ + public function row_array($n = 0) + { + // Make sure $n is not a string + if ( ! is_int($n)) + { + $n = (int) $n; + } + + /* If row_data is initialized, it means that we've already tried + * (at least) to fetch some data, so ... check if we already have + * this row. + */ + if (is_array($this->row_data)) + { + /* If we already have row_data[$n] - return it. + * + * If we enter the elseif, there's a number of reasons to + * return an empty array: + * + * - count($this->row_data) === 0 means there are no results + * - num_rows being set or result_array having count() > 0 means + * that we've already fetched all data and $n is greater than + * our highest row index available + * - $n < $this->current_row means that if such row existed, + * we would've already returned it, therefore $n is an + * invalid index + */ + if (isset($this->row_data[$n])) // We already have this row + { + $this->current_row = $n; + return $this->row_data[$n]; + } + elseif (count($this->row_data) === 0 OR is_int($this->num_rows) + OR count($this->result_array) > 0 OR $n < $this->current_row) + { + // No such row exists + return array(); + } + + // Get the next row index that would actually need to be fetched + $current_row = ($this->current_row < count($this->row_data)) ? count($this->row_data) : $this->current_row + 1; + } + else + { + $current_row = $this->current_row = 0; + $this->row_data = array(); + } + + /* Fetch more data, if available + * + * NOTE: Operator precedence is important here, if you change + * 'AND' with '&&' - it WILL BREAK the results, as + * $row will be assigned the scalar value of both + * expressions! + */ + while ($row = $this->_fetch_assoc() AND $current_row <= $n) + { + $this->row_data[$current_row++] = $row; + } + + // This would mean that there's no (more) data to fetch + if ( ! is_array($this->row_data) OR ! isset($this->row_data[$n])) + { + // Cache what we already have + if (is_array($this->row_data)) + { + $this->num_rows = count($this->row_data); + /* Usually, row_data could have less elements than result_array, + * but at this point - they should be exactly the same. + */ + $this->result_array = $this->row_data; + } + else + { + $this->num_rows = 0; + } + + return array(); + } + + $this->current_row = $n; + return $this->row_data[$n]; + } + + // -------------------------------------------------------------------- + + /* Single row result. Object version. + * + * @param int row index + * @return mixed object if row found; empty array if not + */ + public function row_object($n = 0) + { + // Make sure $n is not a string + if ( ! is_int($n)) + { + $n = (int) $n; + } + + /* Logic here is exactly the same as in row_array, + * except we have to cast row_data[$n] to an object. + * + * If we already have result_object though - we can + * directly return from it. + */ + if (isset($this->result_object[$n])) + { + $this->current_row = $n; + return $this->result_object[$n]; + } + + $row = $this->row_array($n); + // Cast only if the row exists + if (count($row) > 0) + { + $this->current_row = $n; + return (object) $row; + } + + return array(); + } + + // -------------------------------------------------------------------- + + /* Single row result. Custom object version. + * + * @param int row index + * @param string custom class name + * @return mixed custom object if row found; empty array otherwise + */ + public function custom_row_object($n = 0, $class_name) + { + // Make sure $n is not a string + if ( ! is_int($n)) + { + $n = (int) $n; + } + + if (array_key_exists($class_name, $this->custom_result_object)) + { + /* We already have a the whole result set with this class_name, + * return the specified row if it exists, and an empty array if + * it doesn't. + */ + if (isset($this->custom_result_object[$class_name][$n])) + { + $this->current_row = $n; + return $this->custom_result_object[$class_name][$n]; + } + else + { + return array(); + } + } + elseif ( ! class_exists($class_name)) // No such class exists + { + return array(); + } + + $row = $this->row_array($n); + // An array would mean that the row doesn't exist + if (is_array($row)) + { + return $row; + } + + // Convert to the desired class and return + $row_object = new $class_name(); + foreach ($row as $key => $value) + { + $row_object->$key = $value; + } + + $this->current_row = $n; + return $row_object; + } + + // -------------------------------------------------------------------- + + /* First row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function first_row($type = 'object') + { + return $this->row(0, $type); + } + + // -------------------------------------------------------------------- + + /* Last row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function last_row($type = 'object') + { + $result = &$this->result($type); + if ( ! isset($this->num_rows)) + { + $this->num_rows = count($result); + } + $this->current_row = $this->num_rows - 1; + return $result[$this->current_row]; + } + + // -------------------------------------------------------------------- + + /* Next row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function next_row($type = 'object') + { + if (is_array($this->row_data)) + { + $count = count($this->row_data); + $n = ($this->current_row > $count OR ($this->current_row === 0 && $count === 0)) ? $count : $this->current_row + 1; + } + else + { + $n = 0; + } + + return $this->row($n, $type); + } + + // -------------------------------------------------------------------- + + /* Previous row result. + * + * @param string ('object', 'array' or a custom class name) + * @return mixed whatever was passed to the second parameter + */ + public function previous_row($type = 'object') + { + $n = ($this->current_row !== 0) ? $this->current_row - 1 : 0; + return $this->row($n, $type); + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero + * + * @return array + */ + public function _data_seek($n = 0) + { + // Only resetting to the start of the result set is supported + return $this->result_id->reset(); + } + +} + +/* End of file sqlite3_result.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_result.php */ diff --git a/system/database/drivers/sqlite3/sqlite3_utility.php b/system/database/drivers/sqlite3/sqlite3_utility.php new file mode 100644 index 000000000..eae652582 --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_utility.php @@ -0,0 +1,102 @@ +db_debug) + { + return $this->db->display_error('db_unsuported_feature'); + } + } + + // -------------------------------------------------------------------- + + /** + * Optimize table query + * + * Is optimization even supported in SQLite? + * + * @param string the table name + * @return bool + */ + public function _optimize_table($table) + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Repair table query + * + * Are table repairs even supported in SQLite? + * + * @param string the table name + * @return object + */ + public function _repair_table($table) + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * SQLite Export + * + * @param array Preferences + * @return mixed + */ + public function _backup($params = array()) + { + // Not supported + return $this->db->display_error('db_unsuported_feature'); + } +} + +/* End of file sqlite3_utility.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_utility.php */ -- cgit v1.2.3-24-g4f1b From 5cbecb3865c84967692324f283b0bebd7c8efb38 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 16 Jan 2012 13:08:24 +0200 Subject: Add a comment for CI_DB_sqlite3_result::num_rows() --- system/database/drivers/sqlite3/sqlite3_result.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php index 7b1b4502a..c9876fe69 100644 --- a/system/database/drivers/sqlite3/sqlite3_result.php +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -49,6 +49,9 @@ class CI_DB_sqlite3_result extends CI_DB_result { */ public function num_rows() { + /* The SQLite3 driver doesn't have a graceful way to do this, + * so we'll have to do it on our own. + */ return is_int($this->num_rows) ? $this->num_rows : $this->num_rows = count($this->result_array()); -- cgit v1.2.3-24-g4f1b From b5e6f11002a08d29bd0faa2c6c5c437cf9e49523 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 16 Jan 2012 13:25:07 +0200 Subject: Removed some unneeded code and fixed a possible bug --- system/database/drivers/oci8/oci8_result.php | 77 ++++------------------------ 1 file changed, 10 insertions(+), 67 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index fad2465df..e6e932175 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -66,7 +66,7 @@ class CI_DB_oci8_result extends CI_DB_result { } elseif (count($this->result_object) > 0) { - return $this->num_rows = count($this->result_array); + return $this->num_rows = count($this->result_object); } return $this->num_rows = count($this->result_array()); @@ -316,12 +316,10 @@ class CI_DB_oci8_result extends CI_DB_result { return array(); } - // add the data to the object - $result_object = array(); - $data = NULL; - - /* First check if we don't already have the data. - * If so - pass by reference, as we don't know how + /* Even if we didn't have result_array or result_object + * set prior to custom_result_object() being called, + * num_rows() has already done so. + * Pass by reference, as we don't know how * large it might be and we don't want 1000 row * sets being copied. */ @@ -334,70 +332,15 @@ class CI_DB_oci8_result extends CI_DB_result { $data = &$this->result_object; } - if ( ! is_null($data)) + $result_object = array(); + for ($i = 0, $c = count($data); $i < $c; $i++) { - for ($i = 0, $c = count($data); $i < $c; $i++) + $result_object[$i] = new $class_name(); + foreach ($data[$i] as $key => $value) { - $result_object[$i] = new $class_name(); - foreach ($data[$i] as $key => $value) - { - $result_object[$i]->$key = $value; - } + $result_object[$i]->$key = $value; } } - else - { - // No prefetched result set - if (is_array($this->row_data)) - { - $row_index = count($this->row_data); - if ($row_index === 0) - { - return array(); - } - else - { - for ($i = 0; $i < $row_index; $i++) - { - $result_object[$i] = new $class_name(); - foreach ($this->row_data[$i] as $key => $value) - { - $result_object[$i]->$key = $value; - } - } - } - } - else - { - $row_index = 0; - $this->row_data = array(); - } - - while ($row = $this->_fetch_assoc()) - { - $data = new $class_name(); - foreach ($row as $key => $value) - { - $data->$key = $value; - } - - $this->row_data[$row_index] = $row; - $result_object[$row_index++] = $data; - } - // Un-comment the following line, in case it becomes needed - // $this->_data_seek(); - } - - /* As described for the num_rows() method - there's no easy - * way to get the number of rows selected. Our work-around - * solution (as in here as well) first checks if result_array - * or result_object exist and returns their count. It doesn't - * however check for a custom_object_result, so - do it here. - */ - if ( ! is_int($this->num_rows)) - { - $this->num_rows = count($result_object); - } // Cache and return the array return $this->custom_result_object[$class_name] = $result_object; -- cgit v1.2.3-24-g4f1b From 53921cab6f979bedef6deb837aea54f354b1f7e6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 16 Jan 2012 14:35:22 +0200 Subject: Replaced a method with a variable --- system/database/drivers/sqlite3/sqlite3_result.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php index c9876fe69..e8e3706cd 100644 --- a/system/database/drivers/sqlite3/sqlite3_result.php +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -83,7 +83,7 @@ class CI_DB_sqlite3_result extends CI_DB_result { public function list_fields() { $field_names = array(); - for ($i = 0, $c = $this->num_fields(); $i < $this->num_fields(); $i++) + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) { $field_names[] = $this->result_id->columnName($i); } -- cgit v1.2.3-24-g4f1b From c357f5ecb0794fc59802ab7a9779453ee2b003c7 Mon Sep 17 00:00:00 2001 From: Wilbur Suero Date: Tue, 17 Jan 2012 00:17:35 -0400 Subject: Fixed error in inflector_helper.php in the singular function. The function was excepting $singluar_rules and got $singular_values. --- system/helpers/inflector_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 0bd1e112f..2069a1927 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -85,7 +85,7 @@ if ( ! function_exists('singular')) '/([^u])s$/' => '\1', ); - return preg_replace(array_keys($singular_values), $singular_values, $result); + return preg_replace(array_keys($singular_rules), $singular_rules, $result); } } -- cgit v1.2.3-24-g4f1b From eea2ff56657dc5f690523cfcd372b760569ef649 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2012 13:21:53 +0200 Subject: Fix issue #154 --- system/libraries/Session.php | 118 ++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 68 deletions(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 04103a4d9..c4f97e965 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -67,7 +67,7 @@ class CI_Session { */ public function __construct($params = array()) { - log_message('debug', "Session Class Initialized"); + log_message('debug', 'Session Class Initialized'); // Set the super object to a local variable for use throughout the class $this->CI =& get_instance(); @@ -93,14 +93,14 @@ class CI_Session { $this->CI->load->library('encrypt'); } - // Are we using a database? If so, load it + // Are we using a database? If so, load it if ($this->sess_use_database === TRUE AND $this->sess_table_name != '') { $this->CI->load->database(); } - // Set the "now" time. Can either be GMT or server time, based on the - // config prefs. We use this to set the "last activity" time + // Set the "now" time. Can either be GMT or server time, based on the + // config prefs. We use this to set the "last activity" time $this->now = $this->_get_time(); // Set the session length. If the session expiration is @@ -114,7 +114,7 @@ class CI_Session { $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name; // Run the Session routine. If a session doesn't exist we'll - // create a new one. If it does, we'll update it. + // create a new one. If it does, we'll update it. if ( ! $this->sess_read()) { $this->sess_create(); @@ -133,7 +133,7 @@ class CI_Session { // Delete expired sessions if necessary $this->_sess_gc(); - log_message('debug', "Session routines successfully run"); + log_message('debug', 'Session routines successfully run'); } // -------------------------------------------------------------------- @@ -166,7 +166,7 @@ class CI_Session { $hash = substr($session, strlen($session)-32); // get last 32 chars $session = substr($session, 0, strlen($session)-32); - // Does the md5 hash match? This is to prevent manipulation of session data in userspace + // Does the md5 hash match? This is to prevent manipulation of session data in userspace if ($hash !== md5($session.$this->encryption_key)) { log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.'); @@ -179,28 +179,11 @@ class CI_Session { $session = $this->_unserialize($session); // Is the session data we unserialized an array with the correct format? - if ( ! is_array($session) OR ! isset($session['session_id']) OR ! isset($session['ip_address']) OR ! isset($session['user_agent']) OR ! isset($session['last_activity'])) - { - $this->sess_destroy(); - return FALSE; - } - - // Is the session current? - if (($session['last_activity'] + $this->sess_expiration) < $this->now) - { - $this->sess_destroy(); - return FALSE; - } - - // Does the IP Match? - if ($this->sess_match_ip == TRUE AND $session['ip_address'] !== $this->CI->input->ip_address()) - { - $this->sess_destroy(); - return FALSE; - } - - // Does the User Agent Match? - if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) + if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity']) + OR ($session['last_activity'] + $this->sess_expiration) < $this->now // Is the session current? + OR ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) // Does the IP match? + OR ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) // Does the User Agent Match? + ) { $this->sess_destroy(); return FALSE; @@ -223,7 +206,7 @@ class CI_Session { $query = $this->CI->db->get($this->sess_table_name); - // No result? Kill it! + // No result? Kill it! if ($query->num_rows() === 0) { $this->sess_destroy(); @@ -282,7 +265,7 @@ class CI_Session { $cookie_userdata[$val] = $this->userdata[$val]; } - // Did we find any custom data? If not, we turn the empty array into a string + // Did we find any custom data? If not, we turn the empty array into a string // since there's no reason to serialize and store an empty array in the DB if (count($custom_userdata) === 0) { @@ -298,7 +281,7 @@ class CI_Session { $this->CI->db->where('session_id', $this->userdata['session_id']); $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata)); - // Write the cookie. Notice that we manually pass the cookie data array to the + // Write the cookie. Notice that we manually pass the cookie data array to the // _set_cookie() function. Normally that function will store $this->userdata, but // in this case that array contains custom data, which we do not want in the cookie. $this->_set_cookie($cookie_userdata); @@ -324,13 +307,12 @@ class CI_Session { $sessid .= $this->CI->input->ip_address(); $this->userdata = array( - 'session_id' => md5(uniqid($sessid, TRUE)), - 'ip_address' => $this->CI->input->ip_address(), - 'user_agent' => substr($this->CI->input->user_agent(), 0, 120), - 'last_activity' => $this->now, - 'user_data' => '' - ); - + 'session_id' => md5(uniqid($sessid, TRUE)), + 'ip_address' => $this->CI->input->ip_address(), + 'user_agent' => substr($this->CI->input->user_agent(), 0, 120), + 'last_activity' => $this->now, + 'user_data' => '' + ); // Save the data to the DB if needed if ($this->sess_use_database === TRUE) @@ -352,7 +334,8 @@ class CI_Session { public function sess_update() { // We only update the session every five minutes by default - if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now) + if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now + OR $this->CI->input->is_ajax_request()) // Changing the session ID during an AJAX call causes problems { return; } @@ -405,7 +388,7 @@ class CI_Session { public function sess_destroy() { // Kill the session DB row - if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id'])) + if ($this->sess_use_database === TRUE && isset($this->userdata['session_id'])) { $this->CI->db->where('session_id', $this->userdata['session_id']); $this->CI->db->delete($this->sess_table_name); @@ -413,13 +396,13 @@ class CI_Session { // Kill the cookie setcookie( - $this->sess_cookie_name, - addslashes(serialize(array())), - ($this->now - 31500000), - $this->cookie_path, - $this->cookie_domain, - 0 - ); + $this->sess_cookie_name, + addslashes(serialize(array())), + ($this->now - 31500000), + $this->cookie_path, + $this->cookie_domain, + 0 + ); } // -------------------------------------------------------------------- @@ -535,7 +518,7 @@ class CI_Session { */ public function keep_flashdata($key) { - // 'old' flashdata gets removed. Here we mark all + // 'old' flashdata gets removed. Here we mark all // flashdata as 'new' to preserve it from _flashdata_sweep() // Note the function will return FALSE if the $key // provided cannot be found @@ -586,7 +569,6 @@ class CI_Session { * * @return void */ - protected function _flashdata_sweep() { $userdata = $this->all_userdata(); @@ -609,13 +591,9 @@ class CI_Session { */ protected function _get_time() { - if (strtolower($this->time_reference) === 'gmt') - { - $now = time(); - return mktime(gmdate('H', $now), gmdate('i', $now), gmdate('s', $now), gmdate('m', $now), gmdate('d', $now), gmdate('Y', $now)); - } - - return time(); + return (strtolower($this->time_reference) === 'gmt') + ? mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y')) + : time(); } // -------------------------------------------------------------------- @@ -649,13 +627,13 @@ class CI_Session { // Set the cookie setcookie( - $this->sess_cookie_name, - $cookie_data, - $expire, - $this->cookie_path, - $this->cookie_domain, - $this->cookie_secure - ); + $this->sess_cookie_name, + $cookie_data, + $expire, + $this->cookie_path, + $this->cookie_domain, + $this->cookie_secure + ); } // -------------------------------------------------------------------- @@ -687,8 +665,11 @@ class CI_Session { * * This function converts any slashes found into a temporary marker * + * @param string + * @param string + * @return void */ - function _escape_slashes(&$val, $key) + protected function _escape_slashes(&$val, $key) { if (is_string($val)) { @@ -725,6 +706,9 @@ class CI_Session { * * This function converts any slash markers back into actual slashes * + * @param string + * @param string + * @return void */ protected function _unescape_slashes(&$val, $key) { @@ -763,9 +747,7 @@ class CI_Session { } } - } -// END Session Class /* End of file Session.php */ /* Location: ./system/libraries/Session.php */ -- cgit v1.2.3-24-g4f1b From 9c622f373046a0a626799f4ed5a0f944628b0b43 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2012 14:12:54 +0200 Subject: Still update the session on AJAX calls, just don't regenerate the session ID --- system/libraries/Session.php | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index c4f97e965..784bb62b2 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -334,12 +334,40 @@ class CI_Session { public function sess_update() { // We only update the session every five minutes by default - if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now - OR $this->CI->input->is_ajax_request()) // Changing the session ID during an AJAX call causes problems + if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now) { return; } + // _set_cookie() will handle this for us if we aren't using database sessions + // by pushing all userdata to the cookie. + $cookie_data = NULL; + + /* Changing the session ID during an AJAX call causes problems, + * so we'll only update our last_activity + */ + if ($this->CI->input->is_ajax_request()) + { + $this->userdata['last_activity'] = $this->now; + + // Update the session ID and last_activity field in the DB if needed + if ($this->sess_use_database === TRUE) + { + // set cookie explicitly to only have our session data + $cookie_data = array(); + foreach (array('session_id','ip_address','user_agent','last_activity') as $val) + { + $cookie_data[$val] = $this->userdata[$val]; + } + + $this->CI->db->query($this->CI->db->update_string($this->sess_table_name, + array('last_activity' => $this->userdata['last_activity']), + array('session_id' => $this->userdata['session_id']))); + } + + return $this->_set_cookie($cookie_data); + } + // Save the old session id so we know which record to // update in the database if we need it $old_sessid = $this->userdata['session_id']; @@ -357,10 +385,6 @@ class CI_Session { $this->userdata['session_id'] = $new_sessid = md5(uniqid($new_sessid, TRUE)); $this->userdata['last_activity'] = $this->now; - // _set_cookie() will handle this for us if we aren't using database sessions - // by pushing all userdata to the cookie. - $cookie_data = NULL; - // Update the session ID and last_activity field in the DB if needed if ($this->sess_use_database === TRUE) { -- cgit v1.2.3-24-g4f1b From 63a21005ec657aa004b5ffc2b0965c1a201e4637 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2012 15:13:32 +0200 Subject: Some more cleaning --- system/helpers/array_helper.php | 13 ++++--------- system/helpers/captcha_helper.php | 8 ++++---- system/helpers/cookie_helper.php | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index a454f936d..82f0eb16c 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -53,12 +53,7 @@ if ( ! function_exists('element')) { function element($item, $array, $default = FALSE) { - if ( ! isset($array[$item]) OR $array[$item] == "") - { - return $default; - } - - return $array[$item]; + return ( ! isset($array[$item]) OR $array[$item] == '') ? $default : $array[$item]; } } @@ -75,7 +70,7 @@ if ( ! function_exists('random_element')) { function random_element($array) { - return (is_array($array)) ? $array[array_rand($array)] : $array; + return is_array($array) ? $array[array_rand($array)] : $array; } } @@ -105,7 +100,7 @@ if ( ! function_exists('elements')) foreach ($items as $item) { - $return[$item] = (isset($array[$item])) ? $array[$item] : $default; + $return[$item] = isset($array[$item]) ? $array[$item] : $default; } return $return; diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 89bff2366..0565457e2 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -170,7 +170,7 @@ if ( ! function_exists('create_captcha')) } else { - $font_size = 16; + $font_size = 16; $x = rand(0, $img_width/($length/1.5)); $y = $font_size+2; } @@ -192,7 +192,7 @@ if ( ! function_exists('create_captcha')) } - // Create the border + // Create the border imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color); // ----------------------------------- @@ -200,7 +200,7 @@ if ( ! function_exists('create_captcha')) // ----------------------------------- $img_name = $now.'.jpg'; ImageJPEG($im, $img_path.$img_name); - $img = "\""; + $img = ' '; ImageDestroy($im); return array('word' => $word, 'time' => $now, 'image' => $img); diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index d6f836670..52f489b39 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -91,7 +91,7 @@ if ( ! function_exists('get_cookie')) * Delete a COOKIE * * @param mixed - * @param string the cookie domain. Usually: .yourdomain.com + * @param string the cookie domain. Usually: .yourdomain.com * @param string the cookie path * @param string the cookie prefix * @return void -- cgit v1.2.3-24-g4f1b From 2c8baeb0ecdd3f5db299dc8d66edc2f157b64f23 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2012 15:45:28 +0200 Subject: Some more cleaning --- system/libraries/Image_lib.php | 250 +++++++++++++++++------------------------ 1 file changed, 104 insertions(+), 146 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index fd3cd0edb..065f479e8 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Image Manipulation class * @@ -187,22 +185,17 @@ class CI_Image_lib { } } - /* - * Is there a source image? - * - * If not, there's no reason to continue - */ + // Is there a source image? If not, there's no reason to continue if ($this->source_image == '') { $this->set_error('imglib_source_image_required'); return FALSE; } - /* - * Is getimagesize() Available? + /* Is getimagesize() available? * * We use it to determine the image properties (width/height). - * Note: We need to figure out how to determine image + * Note: We need to figure out how to determine image * properties using ImageMagick and NetPBM */ if ( ! function_exists('getimagesize')) @@ -213,8 +206,7 @@ class CI_Image_lib { $this->image_library = strtolower($this->image_library); - /* - * Set the full server path + /* Set the full server path * * The source image may or may not contain a path. * Either way, we'll try use realpath to generate the @@ -244,7 +236,7 @@ class CI_Image_lib { * * If the user has set a "new_image" name it means * we are making a copy of the source image. If not - * it means we are altering the original. We'll + * it means we are altering the original. We'll * set the destination filename and path accordingly. */ if ($this->new_image == '') @@ -252,41 +244,37 @@ class CI_Image_lib { $this->dest_image = $this->source_image; $this->dest_folder = $this->source_folder; } + elseif (strpos($this->new_image, '/') === FALSE) + { + $this->dest_folder = $this->source_folder; + $this->dest_image = $this->new_image; + } else { - if (strpos($this->new_image, '/') === FALSE) + if (function_exists('realpath') && @realpath($this->new_image) !== FALSE) { - $this->dest_folder = $this->source_folder; - $this->dest_image = $this->new_image; + $full_dest_path = str_replace('\\', '/', realpath($this->new_image)); } else { - if (function_exists('realpath') && @realpath($this->new_image) !== FALSE) - { - $full_dest_path = str_replace('\\', '/', realpath($this->new_image)); - } - else - { - $full_dest_path = $this->new_image; - } + $full_dest_path = $this->new_image; + } - // Is there a file name? - if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path)) - { - $this->dest_folder = $full_dest_path.'/'; - $this->dest_image = $this->source_image; - } - else - { - $x = explode('/', $full_dest_path); - $this->dest_image = end($x); - $this->dest_folder = str_replace($this->dest_image, '', $full_dest_path); - } + // Is there a file name? + if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path)) + { + $this->dest_folder = $full_dest_path.'/'; + $this->dest_image = $this->source_image; + } + else + { + $x = explode('/', $full_dest_path); + $this->dest_image = end($x); + $this->dest_folder = str_replace($this->dest_image, '', $full_dest_path); } } - /* - * Compile the finalized filenames/paths + /* Compile the finalized filenames/paths * * We'll create two master strings containing the * full server path to the source image and the @@ -299,7 +287,7 @@ class CI_Image_lib { $this->thumb_marker = ''; } - $xp = $this->explode_name($this->dest_image); + $xp = $this->explode_name($this->dest_image); $filename = $xp['name']; $file_ext = $xp['ext']; @@ -307,8 +295,7 @@ class CI_Image_lib { $this->full_src_path = $this->source_folder.$this->source_image; $this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext; - /* - * Should we maintain image proportions? + /* Should we maintain image proportions? * * When creating thumbs or copies, the target width/height * might not be in correct proportion with the source @@ -319,12 +306,10 @@ class CI_Image_lib { $this->image_reproportion(); } - /* - * Was a width and height specified? + /* Was a width and height specified? * - * If the destination width/height was - * not submitted we will use the values - * from the actual file + * If the destination width/height was not submitted we + * will use the values from the actual file */ if ($this->width == '') { @@ -437,20 +422,15 @@ class CI_Image_lib { } // Choose resizing function - if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm') + if ($this->image_library === 'imagemagick' OR $this->image_library === 'netpbm') { $protocol = 'image_process_'.$this->image_library; return $this->$protocol('rotate'); } - if ($this->rotation_angle == 'hor' OR $this->rotation_angle == 'vrt') - { - return $this->image_mirror_gd(); - } - else - { - return $this->image_rotate_gd(); - } + return ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt') + ? $this->image_mirror_gd() + : $this->image_rotate_gd(); } // -------------------------------------------------------------------- @@ -482,7 +462,7 @@ class CI_Image_lib { // Let's set up our values based on the action if ($action == 'crop') { - // Reassign the source width/height if cropping + // Reassign the source width/height if cropping $this->orig_width = $this->width; $this->orig_height = $this->height; @@ -506,13 +486,14 @@ class CI_Image_lib { return FALSE; } - // Create The Image - // - // old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater" - // it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment - // below should that ever prove inaccurate. - // - // if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE) + /* Create the image + * + * Old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater" + * it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment + * below should that ever prove inaccurate. + * + * if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor') && $v2_override == FALSE) + */ if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor')) { $create = 'imagecreatetruecolor'; @@ -534,21 +515,17 @@ class CI_Image_lib { $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height); - // Show the image + // Show the image if ($this->dynamic_output == TRUE) { $this->image_display_gd($dst_img); } - else + elseif ( ! $this->image_save_gd($dst_img)) // Or save it { - // Or save it - if ( ! $this->image_save_gd($dst_img)) - { - return FALSE; - } + return FALSE; } - // Kill the file handles + // Kill the file handles imagedestroy($dst_img); imagedestroy($src_img); @@ -583,7 +560,7 @@ class CI_Image_lib { } // Execute the command - $cmd = $this->library_path." -quality ".$this->quality; + $cmd = $this->library_path.' -quality '.$this->quality; if ($action == 'crop') { @@ -591,15 +568,8 @@ class CI_Image_lib { } elseif ($action == 'rotate') { - switch ($this->rotation_angle) - { - case 'hor' : $angle = '-flop'; - break; - case 'vrt' : $angle = '-flip'; - break; - default : $angle = '-rotate '.$this->rotation_angle; - break; - } + $angle = ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt') + ? '-flop' : '-rotate '.$this->rotation_angle; $cmd .= ' '.$angle.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; } @@ -642,7 +612,7 @@ class CI_Image_lib { return FALSE; } - // Build the resizing command + // Build the resizing command switch ($this->image_type) { case 1 : @@ -702,7 +672,7 @@ class CI_Image_lib { // If you try manipulating the original it fails so // we have to rename the temp file. copy ($this->dest_folder.'netpbm.tmp', $this->full_dst_path); - unlink ($this->dest_folder.'netpbm.tmp'); + unlink($this->dest_folder.'netpbm.tmp'); @chmod($this->full_dst_path, FILE_WRITE_MODE); return TRUE; @@ -717,7 +687,7 @@ class CI_Image_lib { */ public function image_rotate_gd() { - // Create the image handle + // Create the image handle if ( ! ($src_img = $this->image_create_gd())) { return FALSE; @@ -772,7 +742,7 @@ class CI_Image_lib { $width = $this->orig_width; $height = $this->orig_height; - if ($this->rotation_angle == 'hor') + if ($this->rotation_angle === 'hor') { for ($i = 0; $i < $height; $i++, $left = 0, $right = $width-1) { @@ -839,7 +809,7 @@ class CI_Image_lib { */ public function watermark() { - return ($this->wm_type == 'overlay') ? $this->overlay_watermark() : $this->text_watermark(); + return ($this->wm_type === 'overlay') ? $this->overlay_watermark() : $this->text_watermark(); } // -------------------------------------------------------------------- @@ -861,10 +831,10 @@ class CI_Image_lib { $this->get_image_properties(); // Fetch watermark image properties - $props = $this->get_image_properties($this->wm_overlay_path, TRUE); + $props = $this->get_image_properties($this->wm_overlay_path, TRUE); $wm_img_type = $props['image_type']; - $wm_width = $props['width']; - $wm_height = $props['height']; + $wm_width = $props['width']; + $wm_height = $props['height']; // Create two image resources $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type); @@ -891,25 +861,23 @@ class CI_Image_lib { $y_axis = $this->wm_vrt_offset + $this->wm_padding; // Set the vertical position - switch ($this->wm_vrt_alignment) + if ($this->wm_vrt_alignment === 'M') { - case 'T': - break; - case 'M': $y_axis += ($this->orig_height / 2) - ($wm_height / 2); - break; - case 'B': $y_axis += $this->orig_height - $wm_height; - break; + $y_axis += ($this->orig_height / 2) - ($wm_height / 2); + } + elseif ($this->wm_vrt_alignment === 'B') + { + $y_axis += $this->orig_height - $wm_height; } // Set the horizontal position - switch ($this->wm_hor_alignment) + if ($this->wm_hor_alignment === 'C') { - case 'L': - break; - case 'C': $x_axis += ($this->orig_width / 2) - ($wm_width / 2); - break; - case 'R': $x_axis += $this->orig_width - $wm_width; - break; + $x_axis += ($this->orig_width / 2) - ($wm_width / 2); + } + elseif ($this->wm_hor_alignment === 'R') + { + $x_axis += $this->orig_width - $wm_width; } // Build the finalized image @@ -935,12 +903,12 @@ class CI_Image_lib { imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity); } - // Output the image + // Output the image if ($this->dynamic_output == TRUE) { $this->image_display_gd($src_img); } - elseif ( ! $this->image_save_gd($src_img)) + elseif ( ! $this->image_save_gd($src_img)) // ... or save it { return FALSE; } @@ -977,7 +945,7 @@ class CI_Image_lib { // Reverse the vertical offset // When the image is positioned at the bottom // we don't want the vertical offset to push it - // further down. We want the reverse, so we'll + // further down. We want the reverse, so we'll // invert the offset. Note: The horizontal // offset flips itself automatically @@ -1011,49 +979,39 @@ class CI_Image_lib { $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; - // Set verticle alignment if ($this->wm_use_drop_shadow == FALSE) $this->wm_shadow_distance = 0; $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1)); $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1)); - switch ($this->wm_vrt_alignment) + // Set verticle alignment + if ($this->wm_vrt_alignment === 'M') { - case 'T': - break; - case 'M': $y_axis += ($this->orig_height/2)+($fontheight/2); - break; - case 'B': $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2)); - break; + $y_axis += ($this->orig_height / 2) + ($fontheight / 2); + } + elseif ($this->wm_vrt_alignment === 'B') + { + $y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight / 2); } $x_shad = $x_axis + $this->wm_shadow_distance; $y_shad = $y_axis + $this->wm_shadow_distance; - // Set horizontal alignment - switch ($this->wm_hor_alignment) - { - case 'L': - break; - case 'R': - if ($this->wm_use_drop_shadow) - { - $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text)); - $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text)); - } - break; - case 'C': - if ($this->wm_use_drop_shadow) - { - $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); - $x_axis += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); - } - break; - } - if ($this->wm_use_drop_shadow) { + // Set horizontal alignment + if ($this->wm_hor_alignment === 'R') + { + $x_shad += $this->orig_width - ($fontwidth * strlen($this->wm_text)); + $x_axis += $this->orig_width - ($fontwidth * strlen($this->wm_text)); + } + elseif ($this->wm_hor_alignment === 'C') + { + $x_shad += floor(($this->orig_width - ($fontwidth * strlen($this->wm_text))) / 2); + $x_axis += floor(($this->orig_width - ($fontwidth * strlen($this->wm_text))) / 2); + } + /* Set RGB values for text and shadow * * First character is #, so we don't really need it. @@ -1222,8 +1180,8 @@ class CI_Image_lib { */ public function image_display_gd($resource) { - header("Content-Disposition: filename={$this->source_image};"); - header("Content-Type: {$this->mime_type}"); + header('Content-Disposition: filename='.$this->source_image.';'); + header('Content-Type: '.$this->mime_type); header('Content-Transfer-Encoding: binary'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); @@ -1351,15 +1309,15 @@ class CI_Image_lib { * Size calculator * * This function takes a known width x height and - * recalculates it to a new size. Only one + * recalculates it to a new size. Only one * new variable needs to be known * * $props = array( - * 'width' => $width, - * 'height' => $height, - * 'new_width' => 40, - * 'new_height' => '' - * ); + * 'width' => $width, + * 'height' => $height, + * 'new_width' => 40, + * 'new_height' => '' + * ); * * @param array * @return array @@ -1403,7 +1361,7 @@ class CI_Image_lib { * * This is a helper function that extracts the extension * from the source_image. This function lets us deal with - * source_images with multiple periods, like: my.cool.jpg + * source_images with multiple periods, like: my.cool.jpg * It returns an associative array with two elements: * $array['ext'] = '.jpg'; * $array['name'] = 'my.cool'; @@ -1498,7 +1456,7 @@ class CI_Image_lib { */ public function display_errors($open = '

', $close = '

') { - return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : ''; + return (count($this->error_msg) > 0) ? $open.implode($close.$open, $this->error_msg).$close : ''; } } -- cgit v1.2.3-24-g4f1b From e35d7789a24e811bc147bc56c7a1d79904900b01 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2012 15:56:20 +0200 Subject: Some more cleaning --- system/database/drivers/oci8/oci8_driver.php | 17 +++-------------- system/database/drivers/oci8/oci8_result.php | 3 +-- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 2a5149f9e..f4b899cf3 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -46,7 +46,6 @@ * permit access to oracle databases * * @author Kelly McArdle - * */ class CI_DB_oci8_driver extends CI_DB { @@ -249,7 +248,7 @@ class CI_DB_oci8_driver extends CI_DB { } // build the query string - $sql = "BEGIN {$package}.{$procedure}("; + $sql = 'BEGIN '.$package.'.'.$procedure.'('; $have_cursor = FALSE; foreach ($params as $param) @@ -359,13 +358,8 @@ class CI_DB_oci8_driver extends CI_DB { */ public function trans_rollback() { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } @@ -614,12 +608,7 @@ class CI_DB_oci8_driver extends CI_DB { */ protected function _from_tables($tables) { - if ( ! is_array($tables)) - { - $tables = array($tables); - } - - return implode(', ', $tables); + return is_array($tables) ? implode(', ', $tables) : $tables; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index e6e932175..0e0fe059d 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -194,7 +194,7 @@ class CI_DB_oci8_result extends CI_DB_result { // -------------------------------------------------------------------- /** - * Query result. "array" version. + * Query result. Array version. * * @return array */ @@ -516,7 +516,6 @@ class CI_DB_oci8_result extends CI_DB_result { * @param string custom class name * @return mixed custom object if row found; empty array otherwise */ - public function custom_row_object($n = 0, $class_name) { // Make sure $n is not a string -- cgit v1.2.3-24-g4f1b From 72d7a6e2cbf1bd797bab7b14912a207f4522953a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2012 16:02:32 +0200 Subject: Some cleaning --- system/database/drivers/sqlite3/sqlite3_driver.php | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index b82ae1ecd..8a7dbe1f1 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -188,13 +188,8 @@ class CI_DB_sqlite3_driver extends CI_DB { */ public function trans_begin($test_mode = FALSE) { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } @@ -216,13 +211,8 @@ class CI_DB_sqlite3_driver extends CI_DB { */ public function trans_commit() { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } @@ -239,13 +229,8 @@ class CI_DB_sqlite3_driver extends CI_DB { */ public function trans_rollback() { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } -- cgit v1.2.3-24-g4f1b From 7e087f5e07c4630092a1d6ecdd103dc15f48e573 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 11:46:27 +0200 Subject: Revert if() merge, for readability --- system/libraries/Session.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 784bb62b2..b8c623584 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -179,11 +179,28 @@ class CI_Session { $session = $this->_unserialize($session); // Is the session data we unserialized an array with the correct format? - if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity']) - OR ($session['last_activity'] + $this->sess_expiration) < $this->now // Is the session current? - OR ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) // Does the IP match? - OR ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) // Does the User Agent Match? - ) + if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity'])) + { + $this->sess_destroy(); + return FALSE; + } + + // Is the session current? + if (($session['last_activity'] + $this->sess_expiration) < $this->now) + { + $this->sess_destroy(); + return FALSE; + } + + // Does the IP match? + if ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) + { + $this->sess_destroy(); + return FALSE; + } + + // Does the User Agent Match? + if ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) { $this->sess_destroy(); return FALSE; -- cgit v1.2.3-24-g4f1b From 1ab62aedc09cc75ac5619d5e881076cc9ca5e090 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:04:10 +0200 Subject: Replaced AND with && --- system/database/DB_driver.php | 53 +++++++++++++--------------- system/database/drivers/oci8/oci8_driver.php | 2 +- system/database/drivers/oci8/oci8_result.php | 1 - 3 files changed, 25 insertions(+), 31 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index e667c25d3..7f5ec1e20 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -106,7 +106,7 @@ class CI_DB_driver { * Initialize Database Settings * * @param mixed - * @return void + * @return bool */ public function initialize() { @@ -198,7 +198,7 @@ class CI_DB_driver { * * @param string * @param string - * @return resource + * @return bool */ public function db_set_charset($charset, $collation) { @@ -292,15 +292,15 @@ class CI_DB_driver { } // Verify table prefix and replace if necessary - if ( ($this->dbprefix != '' AND $this->swap_pre != '') AND ($this->dbprefix != $this->swap_pre) ) + if (($this->dbprefix != '' && $this->swap_pre != '') && ($this->dbprefix != $this->swap_pre)) { - $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql); + $sql = preg_replace('/(\W)'.$this->swap_pre.'(\S+?)/', '\\1'.$this->dbprefix.'\\2', $sql); } // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists - if ($this->cache_on == TRUE AND stristr($sql, 'SELECT')) + if ($this->cache_on == TRUE && stristr($sql, 'SELECT')) { if ($this->_cache_init()) { @@ -385,7 +385,7 @@ class CI_DB_driver { { // If caching is enabled we'll auto-cleanup any // existing files related to this particular URI - if ($this->cache_on == TRUE AND $this->cache_autodel == TRUE AND $this->_cache_init()) + if ($this->cache_on == TRUE && $this->cache_autodel == TRUE && $this->_cache_init()) { $this->CACHE->delete(); } @@ -419,7 +419,7 @@ class CI_DB_driver { // Is query caching enabled? If so, we'll serialize the // result object and save it to a cache file. - if ($this->cache_on == TRUE AND $this->_cache_init()) + if ($this->cache_on == TRUE && $this->_cache_init()) { // We'll create a new instance of the result object // only without the platform specific driver since @@ -489,7 +489,6 @@ class CI_DB_driver { * Disable Transactions * This permits transactions to be disabled at run-time. * - * @access public * @return void */ public function trans_off() @@ -501,12 +500,12 @@ class CI_DB_driver { /** * Enable/disable Transaction Strict Mode + * * When strict mode is enabled, if you are running multiple groups of * transactions, if one group fails all groups will be rolled back. * If strict mode is disabled, each group is treated autonomously, meaning * a failure of one group will not affect any others * - * @access public * @return void */ public function trans_strict($mode = TRUE) @@ -645,15 +644,11 @@ class CI_DB_driver { * Determines if a query is a "write" type. * * @param string An SQL query string - * @return boolean + * @return bool */ public function is_write_type($sql) { - if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql)) - { - return FALSE; - } - return TRUE; + return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql); } // -------------------------------------------------------------------- @@ -661,8 +656,8 @@ class CI_DB_driver { /** * Calculate the aggregate query elapsed time * - * @param integer The number of decimal places - * @return integer + * @param int The number of decimal places + * @return string */ public function elapsed_time($decimals = 6) { @@ -743,7 +738,7 @@ class CI_DB_driver { /** * Primary * - * Retrieves the primary key. It assumes that the row in the first + * Retrieves the primary key. It assumes that the row in the first * position is the primary key * * @param string the table name @@ -946,7 +941,7 @@ class CI_DB_driver { { if ($where == '') { - return false; + return FALSE; } $fields = array(); @@ -1118,12 +1113,12 @@ class CI_DB_driver { */ private function _cache_init() { - if (is_object($this->CACHE) AND class_exists('CI_DB_Cache')) + if (is_object($this->CACHE) && class_exists('CI_DB_Cache')) { return TRUE; } - if ( ! class_exists('CI_DB_Cache') AND ! @include(BASEPATH.'database/DB_cache.php')) + if ( ! class_exists('CI_DB_Cache') && ! @include(BASEPATH.'database/DB_cache.php')) { return $this->cache_off(); } @@ -1221,7 +1216,7 @@ class CI_DB_driver { * a couple functions in this class. * It takes a column or table name (optionally with an alias) and inserts * the table prefix onto it. Some logic is necessary in order to deal with - * column names that include the path. Consider a query like this: + * column names that include the path. Consider a query like this: * * SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table * @@ -1289,7 +1284,7 @@ class CI_DB_driver { $parts = explode('.', $item); // Does the first segment of the exploded item match - // one of the aliases previously identified? If so, + // one of the aliases previously identified? If so, // we have nothing more to do other than escape the item if (in_array($parts[0], $this->ar_aliased_tables)) { @@ -1308,7 +1303,7 @@ class CI_DB_driver { return $item.$alias; } - // Is there a table prefix defined in the config file? If not, no need to do anything + // Is there a table prefix defined in the config file? If not, no need to do anything if ($this->dbprefix != '') { // We now add the table prefix based on some logic. @@ -1341,7 +1336,7 @@ class CI_DB_driver { // Verify table prefix and replace if necessary if ($this->swap_pre != '' && strncmp($parts[$i], $this->swap_pre, strlen($this->swap_pre)) === 0) { - $parts[$i] = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $parts[$i]); + $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]); } // We only add the table prefix if it does not already exist @@ -1362,23 +1357,23 @@ class CI_DB_driver { return $item.$alias; } - // Is there a table prefix? If not, no need to insert it + // Is there a table prefix? If not, no need to insert it if ($this->dbprefix != '') { // Verify table prefix and replace if necessary if ($this->swap_pre != '' && strncmp($item, $this->swap_pre, strlen($this->swap_pre)) === 0) { - $item = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $item); + $item = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $item); } // Do we prefix an item with no segments? - if ($prefix_single == TRUE AND substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix) + if ($prefix_single == TRUE && substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix) { $item = $this->dbprefix.$item; } } - if ($protect_identifiers === TRUE AND ! in_array($item, $this->_reserved_identifiers)) + if ($protect_identifiers === TRUE && ! in_array($item, $this->_reserved_identifiers)) { $item = $this->_escape_identifiers($item); } diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index f4b899cf3..76aca9a66 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -471,7 +471,7 @@ class CI_DB_oci8_driver extends CI_DB { { $sql = 'SELECT TABLE_NAME FROM ALL_TABLES'; - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix != '') { return $sql." WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 0e0fe059d..221ab2c5f 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -358,7 +358,6 @@ class CI_DB_oci8_result extends CI_DB_result { * @param string ('object', 'array' or a custom class name) * @return mixed whatever was passed to the second parameter */ - public function row($n = 0, $type = 'object') { if ($type === 'object') -- cgit v1.2.3-24-g4f1b From 5ad9e4ebba4ab8a8eb36952430d5a18978697360 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:10:22 +0200 Subject: Replace AND with && --- system/helpers/captcha_helper.php | 4 +--- system/helpers/cookie_helper.php | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'system') diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 0565457e2..3b62da929 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter CAPTCHA Helper * @@ -160,7 +158,7 @@ if ( ! function_exists('create_captcha')) // ----------------------------------- // Write the text // ----------------------------------- - $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE; + $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext')); if ($use_font == FALSE) { diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 52f489b39..f32a1a5ae 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Cookie Helpers * -- cgit v1.2.3-24-g4f1b From f88681873b8b556d58f22a3e99c916eadbcb6171 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:14:53 +0200 Subject: Replace AND with && --- system/libraries/Session.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index b8c623584..c331d99f7 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Session Class * @@ -94,7 +92,7 @@ class CI_Session { } // Are we using a database? If so, load it - if ($this->sess_use_database === TRUE AND $this->sess_table_name != '') + if ($this->sess_use_database === TRUE && $this->sess_table_name != '') { $this->CI->load->database(); } @@ -232,7 +230,7 @@ class CI_Session { // Is there custom data? If so, add it to the main session array $row = $query->row(); - if (isset($row->user_data) AND $row->user_data != '') + if (isset($row->user_data) && $row->user_data != '') { $custom_data = $this->_unserialize($row->user_data); -- cgit v1.2.3-24-g4f1b From 6de924ce72797a1a8d8d8104f767f42c24e929c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:18:18 +0200 Subject: Replace AND with && --- system/libraries/Form_validation.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 9aa07a1a8..34b7b646d 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -297,7 +297,7 @@ class CI_Form_validation { // Is there a validation rule for the particular URI being accessed? $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group; - if ($uri != '' AND isset($this->_config_rules[$uri])) + if ($uri != '' && isset($this->_config_rules[$uri])) { $this->set_rules($this->_config_rules[$uri]); } @@ -327,7 +327,7 @@ class CI_Form_validation { { $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); } - elseif (isset($_POST[$field]) AND $_POST[$field] != '') + elseif (isset($_POST[$field]) && $_POST[$field] != '') { $this->_field_data[$field]['postdata'] = $_POST[$field]; } @@ -373,7 +373,7 @@ class CI_Form_validation { /** * Re-populate the _POST array with our finalized and processed data * - * @return null + * @return void */ protected function _reset_post_array() { @@ -452,7 +452,7 @@ class CI_Form_validation { // If the field is blank, but NOT required, no further tests are necessary $callback = FALSE; - if ( ! in_array('required', $rules) AND is_null($postdata)) + if ( ! in_array('required', $rules) && is_null($postdata)) { // Before we bail out, does the rule contain a callback? if (preg_match('/(callback_\w+(\[.*?\])?)/', implode(' ', $rules), $match)) @@ -467,7 +467,7 @@ class CI_Form_validation { } // Isset Test. Typically this rule will only apply to checkboxes. - if (is_null($postdata) AND $callback === FALSE) + if (is_null($postdata) && $callback === FALSE) { if (in_array('isset', $rules, TRUE) OR in_array('required', $rules)) { @@ -510,7 +510,7 @@ class CI_Form_validation { // We set the $postdata variable with the current data in our master array so that // each cycle of the loop is dealing with the processed data from the last cycle - if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata'])) + if ($row['is_array'] == TRUE && is_array($this->_field_data[$row['field']]['postdata'])) { // We shouldn't need this safety, but just in case there isn't an array index // associated with this cycle we'll bail out @@ -569,7 +569,7 @@ class CI_Form_validation { } // If the field isn't required and we just processed a callback we'll move on... - if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE) + if ( ! in_array('required', $rules, TRUE) && $result !== FALSE) { continue; } @@ -724,7 +724,7 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -759,7 +759,7 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - return ($default === TRUE AND count($this->_field_data) === 0) ? ' checked="checked"' : ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' checked="checked"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -1125,7 +1125,7 @@ class CI_Form_validation { */ public function is_natural_no_zero($str) { - return ($str != 0 AND preg_match('/^[0-9]+$/', $str)); + return ($str != 0 && preg_match('/^[0-9]+$/', $str)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 16d806605993305efe9c264b3ae8383ec92ae5ae Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:26:49 +0200 Subject: Some more cleaning --- system/libraries/Zip.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index dbcdb2d97..85a0b5ce9 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Zip Compression Class * @@ -265,7 +263,7 @@ class CI_Zip { * Read a directory and add it to the zip. * * This function recursively reads a folder and everything it contains (including - * sub-folders) and creates a zip based on it. Whatever directory structure + * sub-folders) and creates a zip based on it. Whatever directory structure * is in the original file path will be recreated in the zip file. * * @param string path to source @@ -297,18 +295,14 @@ class CI_Zip { { $this->read_dir($path.$file.'/', $preserve_filepath, $root_path); } - else + elseif (FALSE !== ($data = file_get_contents($path.$file))) { - if (FALSE !== ($data = file_get_contents($path.$file))) + $name = str_replace('\\', '/', $path); + if ($preserve_filepath === FALSE) { - $name = str_replace('\\', '/', $path); - if ($preserve_filepath === FALSE) - { - $name = str_replace($root_path, '', $name); - } - - $this->add_data($name.$file, $data); + $name = str_replace($root_path, '', $name); } + $this->add_data($name.$file, $data); } } @@ -320,7 +314,7 @@ class CI_Zip { /** * Get the Zip file * - * @return binary string + * @return string (binary encoded) */ public function get_zip() { @@ -393,10 +387,10 @@ class CI_Zip { /** * Initialize Data * - * Lets you clear current zip data. Useful if you need to create + * Lets you clear current zip data. Useful if you need to create * multiple zips with different data. * - * @return void + * @return object */ public function clear_data() { -- cgit v1.2.3-24-g4f1b From 342a466b4739b9c3dd05c417d1ae56f0ca14fd8d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:24:00 +0200 Subject: Revert a space in the license agreement :) --- system/database/drivers/oci8/oci8_driver.php | 2 +- system/database/drivers/oci8/oci8_forge.php | 2 +- system/database/drivers/oci8/oci8_result.php | 2 +- system/database/drivers/oci8/oci8_utility.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 76aca9a66..58d9b9ba3 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 6b9a8e8fd..35587a9cc 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 221ab2c5f..7781b5bbd 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index 38d870aa6..3fee6a1b6 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 -- cgit v1.2.3-24-g4f1b From f20fb98b36cba430e20eea931e9be392031923ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:26:01 +0200 Subject: Revert a space in the license agreement :) --- system/database/drivers/sqlite3/sqlite3_driver.php | 2 +- system/database/drivers/sqlite3/sqlite3_forge.php | 2 +- system/database/drivers/sqlite3/sqlite3_result.php | 2 +- system/database/drivers/sqlite3/sqlite3_utility.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index 8a7dbe1f1..b14e06c5d 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index 07c25515a..a94970180 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php index e8e3706cd..acda28e6a 100644 --- a/system/database/drivers/sqlite3/sqlite3_result.php +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/database/drivers/sqlite3/sqlite3_utility.php b/system/database/drivers/sqlite3/sqlite3_utility.php index eae652582..bc9898ee4 100644 --- a/system/database/drivers/sqlite3/sqlite3_utility.php +++ b/system/database/drivers/sqlite3/sqlite3_utility.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 -- cgit v1.2.3-24-g4f1b From 51a22815994cfd4522c78177e41f064ab8e53415 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:27:34 +0200 Subject: Revert a space in the license agreement :) --- system/helpers/array_helper.php | 2 +- system/helpers/captcha_helper.php | 2 +- system/helpers/cookie_helper.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 82f0eb16c..45eaa4c10 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 3b62da929..c302a828b 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index f32a1a5ae..af2e1df80 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 -- cgit v1.2.3-24-g4f1b From a3d19c4ac63c4af1c2b823b0962e6be79e89d186 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:29:29 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 065f479e8..5ea830fb1 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 -- cgit v1.2.3-24-g4f1b From 1841e6b472820deb2dfe4d43c675211eeabbd057 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:30:01 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 85a0b5ce9..e7c55de1b 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 -- cgit v1.2.3-24-g4f1b From b998f3e820c724f16f3b700f094c875af1d28c0f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:31:26 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 34b7b646d..20f1faf27 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 -- cgit v1.2.3-24-g4f1b From f863a02e314813753662106459e93f6675b1566e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:31:54 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index c331d99f7..66b39a6a2 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * 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 + * 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 -- cgit v1.2.3-24-g4f1b From a3ed086e74f6ea2fc8a529e02e509bbf91dd13c5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 25 Jan 2012 14:46:52 +0200 Subject: Remove an access description line and switch private to protected --- system/database/drivers/sqlite3/sqlite3_driver.php | 2 +- system/database/drivers/sqlite3/sqlite3_result.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index b14e06c5d..2e6589b52 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -174,7 +174,7 @@ class CI_DB_sqlite3_driver extends CI_DB { * @param string an SQL query * @return string */ - private function _prep_query($sql) + protected function _prep_query($sql) { return $this->conn_id->prepare($sql); } diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php index acda28e6a..c88696328 100644 --- a/system/database/drivers/sqlite3/sqlite3_result.php +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -153,7 +153,6 @@ class CI_DB_sqlite3_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ protected function _fetch_object() -- cgit v1.2.3-24-g4f1b From af5d5586a5040de24335e483edb17a2657ddeb21 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 25 Jan 2012 21:34:47 +0200 Subject: Improve the base database driver class --- system/database/DB_driver.php | 502 ++++++++++++++++-------------------------- 1 file changed, 189 insertions(+), 313 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 661b42ced..d9d83d55d 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1,13 +1,13 @@ -conn_id) OR is_object($this->conn_id)) + /* If an established connection is available, then there's + * no need to connect and select the database. + * + * Depending on the database driver, conn_id can be either + * boolean TRUE, a resource or an object. + */ + if ($this->conn_id) { return TRUE; } @@ -126,7 +123,7 @@ class CI_DB_driver { // Connect to the database and set the connection ID $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); - // No connection resource? Check if there is a failover else throw an error + // No connection resource? Check if there is a failover else throw an error if ( ! $this->conn_id) { // Check if there is a failover set @@ -200,12 +197,11 @@ class CI_DB_driver { /** * Set client character set * - * @access public * @param string * @param string - * @return resource + * @return bool */ - function db_set_charset($charset, $collation) + public function db_set_charset($charset, $collation) { if ( ! $this->_db_set_charset($this->char_set, $this->dbcollat)) { @@ -227,10 +223,9 @@ class CI_DB_driver { /** * The name of the platform in use (mysql, mssql, etc...) * - * @access public * @return string */ - function platform() + public function platform() { return $this->dbdriver; } @@ -238,21 +233,16 @@ class CI_DB_driver { // -------------------------------------------------------------------- /** - * Database Version Number. Returns a string containing the + * Database Version Number. Returns a string containing the * version of the database being used * - * @access public * @return string */ - function version() + public function version() { if (FALSE === ($sql = $this->_version())) { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; } // Some DBs have functions that return the version, and don't run special @@ -266,7 +256,8 @@ class CI_DB_driver { else { $query = $this->query($sql); - return $query->row('ver'); + $query = $query->row(); + return $query->ver; } } @@ -281,42 +272,34 @@ class CI_DB_driver { * FALSE upon failure, and if the $db_debug variable is set to TRUE * will raise an error. * - * @access public * @param string An SQL query string * @param array An array of binding data * @return mixed */ - function query($sql, $binds = FALSE, $return_object = TRUE) + public function query($sql, $binds = FALSE, $return_object = TRUE) { if ($sql == '') { log_message('error', 'Invalid query: '.$sql); - if ($this->db_debug) - { - return $this->display_error('db_invalid_query'); - } - return FALSE; + return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE; } // Verify table prefix and replace if necessary - if ( ($this->dbprefix != '' AND $this->swap_pre != '') AND ($this->dbprefix != $this->swap_pre) ) + if ( ($this->dbprefix != '' && $this->swap_pre != '') && ($this->dbprefix != $this->swap_pre) ) { - $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql); + $sql = preg_replace('/(\W)'.$this->swap_pre.'(\S+?)/', '\\1'.$this->dbprefix.'\\2', $sql); } - // Is query caching enabled? If the query is a "read type" + // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists - if ($this->cache_on == TRUE AND stristr($sql, 'SELECT')) + if ($this->cache_on == TRUE && stripos($sql, 'SELECT') !== FALSE && $this->_cache_init()) { - if ($this->_cache_init()) + $this->load_rdriver(); + if (FALSE !== ($cache = $this->CACHE->read($sql))) { - $this->load_rdriver(); - if (FALSE !== ($cache = $this->CACHE->read($sql))) - { - return $cache; - } + return $cache; } } @@ -326,7 +309,7 @@ class CI_DB_driver { $sql = $this->compile_binds($sql, $binds); } - // Save the query for debugging + // Save the query for debugging if ($this->save_queries == TRUE) { $this->queries[] = $sql; @@ -357,19 +340,13 @@ class CI_DB_driver { if ($this->db_debug) { // We call this function in order to roll-back queries - // if transactions are enabled. If we don't call this here + // if transactions are enabled. If we don't call this here // the error message will trigger an exit, causing the // transactions to remain in limbo. $this->trans_complete(); // Display errors - return $this->display_error( - array( - 'Error Number: '.$error_no, - $error_msg, - $sql - ) - ); + return $this->display_error(array('Error Number: '.$error_no, $error_msg, $sql)); } return FALSE; @@ -393,7 +370,7 @@ class CI_DB_driver { { // If caching is enabled we'll auto-cleanup any // existing files related to this particular URI - if ($this->cache_on == TRUE AND $this->cache_autodel == TRUE AND $this->_cache_init()) + if ($this->cache_on == TRUE && $this->cache_autodel == TRUE && $this->_cache_init()) { $this->CACHE->delete(); } @@ -410,13 +387,12 @@ class CI_DB_driver { } // Load and instantiate the result driver - - $driver = $this->load_rdriver(); - $RES = new $driver(); + $driver = $this->load_rdriver(); + $RES = new $driver(); $RES->conn_id = $this->conn_id; $RES->result_id = $this->result_id; - if ($this->dbdriver == 'oci8') + if ($this->dbdriver === 'oci8') { $RES->stmt_id = $this->stmt_id; $RES->curs_id = NULL; @@ -427,9 +403,9 @@ class CI_DB_driver { // oci8 vars must be set before calling this $RES->num_rows = $RES->num_rows(); - // Is query caching enabled? If so, we'll serialize the + // Is query caching enabled? If so, we'll serialize the // result object and save it to a cache file. - if ($this->cache_on == TRUE AND $this->_cache_init()) + if ($this->cache_on == TRUE && $this->_cache_init()) { // We'll create a new instance of the result object // only without the platform specific driver since @@ -438,9 +414,9 @@ class CI_DB_driver { // result object, so we'll have to compile the data // and save it) $CR = new CI_DB_result(); - $CR->num_rows = $RES->num_rows(); $CR->result_object = $RES->result_object(); $CR->result_array = $RES->result_array(); + $CR->num_rows = $RES->num_rows(); // Reset these since cached objects can not utilize resource IDs. $CR->conn_id = NULL; @@ -457,10 +433,9 @@ class CI_DB_driver { /** * Load the result drivers * - * @access public * @return string the name of the result class */ - function load_rdriver() + public function load_rdriver() { $driver = 'CI_DB_'.$this->dbdriver.'_result'; @@ -477,15 +452,14 @@ class CI_DB_driver { /** * Simple Query - * This is a simplified version of the query() function. Internally + * This is a simplified version of the query() function. Internally * we only use it when running transaction commands since they do * not require all the features of the main query() function. * - * @access public * @param string the sql query * @return mixed */ - function simple_query($sql) + public function simple_query($sql) { if ( ! $this->conn_id) { @@ -501,10 +475,9 @@ class CI_DB_driver { * Disable Transactions * This permits transactions to be disabled at run-time. * - * @access public * @return void */ - function trans_off() + public function trans_off() { $this->trans_enabled = FALSE; } @@ -518,10 +491,9 @@ class CI_DB_driver { * If strict mode is disabled, each group is treated autonomously, meaning * a failure of one group will not affect any others * - * @access public * @return void */ - function trans_strict($mode = TRUE) + public function trans_strict($mode = TRUE) { $this->trans_strict = is_bool($mode) ? $mode : TRUE; } @@ -531,10 +503,9 @@ class CI_DB_driver { /** * Start Transaction * - * @access public * @return void */ - function trans_start($test_mode = FALSE) + public function trans_start($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -557,10 +528,9 @@ class CI_DB_driver { /** * Complete Transaction * - * @access public * @return bool */ - function trans_complete() + public function trans_complete() { if ( ! $this->trans_enabled) { @@ -604,10 +574,9 @@ class CI_DB_driver { /** * Lets you retrieve the transaction flag to determine if it has failed * - * @access public * @return bool */ - function trans_status() + public function trans_status() { return $this->_trans_status; } @@ -617,12 +586,11 @@ class CI_DB_driver { /** * Compile Bindings * - * @access public * @param string the sql statement * @param array an array of bind data * @return string */ - function compile_binds($sql, $binds) + public function compile_binds($sql, $binds) { if (strpos($sql, $this->bind_marker) === FALSE) { @@ -639,7 +607,8 @@ class CI_DB_driver { // The count of bind should be 1 less then the count of segments // If there are more bind arguments trim it down - if (count($binds) >= count($segments)) { + if (count($binds) >= count($segments)) + { $binds = array_slice($binds, 0, count($segments)-1); } @@ -648,8 +617,7 @@ class CI_DB_driver { $i = 0; foreach ($binds as $bind) { - $result .= $this->escape($bind); - $result .= $segments[++$i]; + $result .= $this->escape($bind).$segments[++$i]; } return $result; @@ -660,17 +628,12 @@ class CI_DB_driver { /** * Determines if a query is a "write" type. * - * @access public * @param string An SQL query string - * @return boolean + * @return bool */ - function is_write_type($sql) + public function is_write_type($sql) { - if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql)) - { - return FALSE; - } - return TRUE; + return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql); } // -------------------------------------------------------------------- @@ -678,11 +641,10 @@ class CI_DB_driver { /** * Calculate the aggregate query elapsed time * - * @access public - * @param integer The number of decimal places - * @return integer + * @param int The number of decimal places + * @return int */ - function elapsed_time($decimals = 6) + public function elapsed_time($decimals = 6) { return number_format($this->benchmark, $decimals); } @@ -692,10 +654,9 @@ class CI_DB_driver { /** * Returns the total number of queries * - * @access public - * @return integer + * @return int */ - function total_queries() + public function total_queries() { return $this->query_count; } @@ -705,10 +666,9 @@ class CI_DB_driver { /** * Returns the last query that was executed * - * @access public - * @return void + * @return string */ - function last_query() + public function last_query() { return end($this->queries); } @@ -721,23 +681,22 @@ class CI_DB_driver { * Escapes data based on type * Sets boolean and null types * - * @access public * @param string * @return mixed */ - function escape($str) + public function escape($str) { if (is_string($str)) { - $str = "'".$this->escape_str($str)."'"; + return "'".$this->escape_str($str)."'"; } elseif (is_bool($str)) { - $str = ($str === FALSE) ? 0 : 1; + return ($str === FALSE) ? 0 : 1; } elseif (is_null($str)) { - $str = 'NULL'; + return 'NULL'; } return $str; @@ -751,11 +710,10 @@ class CI_DB_driver { * Calls the individual driver for platform * specific escaping for LIKE conditions * - * @access public * @param string * @return mixed */ - function escape_like_str($str) + public function escape_like_str($str) { return $this->escape_str($str, TRUE); } @@ -765,23 +723,16 @@ class CI_DB_driver { /** * Primary * - * Retrieves the primary key. It assumes that the row in the first + * Retrieves the primary key. It assumes that the row in the first * position is the primary key * - * @access public * @param string the table name * @return string */ - function primary($table = '') + public function primary($table = '') { $fields = $this->list_fields($table); - - if ( ! is_array($fields)) - { - return FALSE; - } - - return current($fields); + return is_array($fields) ? current($fields) : FALSE; } // -------------------------------------------------------------------- @@ -789,10 +740,9 @@ class CI_DB_driver { /** * Returns an array of table names * - * @access public * @return array */ - function list_tables($constrain_by_prefix = FALSE) + public function list_tables($constrain_by_prefix = FALSE) { // Is there a cached result? if (isset($this->data_cache['table_names'])) @@ -802,32 +752,17 @@ class CI_DB_driver { if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; } - $retval = array(); + $this->data_cache['table_names'] = array(); $query = $this->query($sql); - if ($query->num_rows() > 0) + foreach ($query->result_array() as $row) { - foreach ($query->result_array() as $row) - { - if (isset($row['TABLE_NAME'])) - { - $retval[] = $row['TABLE_NAME']; - } - else - { - $retval[] = array_shift($row); - } - } + $this->data_cache['table_names'][] = isset($row['TABLE_NAME']) ? $row['TABLE_NAME'] : array_shift($row); } - $this->data_cache['table_names'] = $retval; return $this->data_cache['table_names']; } @@ -835,12 +770,12 @@ class CI_DB_driver { /** * Determine if a particular table exists - * @access public - * @return boolean + * + * @return bool */ - function table_exists($table_name) + public function table_exists($table_name) { - return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE; + return in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables()); } // -------------------------------------------------------------------- @@ -848,11 +783,10 @@ class CI_DB_driver { /** * Fetch MySQL Field Names * - * @access public * @param string the table name * @return array */ - function list_fields($table = '') + public function list_fields($table = '') { // Is there a cached result? if (isset($this->data_cache['field_names'][$table])) @@ -862,38 +796,22 @@ class CI_DB_driver { if ($table == '') { - if ($this->db_debug) - { - return $this->display_error('db_field_param_missing'); - } - return FALSE; + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } if (FALSE === ($sql = $this->_list_columns($table))) { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; } $query = $this->query($sql); + $this->data_cache['field_names'][$table] = array(); - $retval = array(); foreach ($query->result_array() as $row) { - if (isset($row['COLUMN_NAME'])) - { - $retval[] = $row['COLUMN_NAME']; - } - else - { - $retval[] = current($row); - } + $this->data_cache['field_names'][$table][] = isset($row['COLUMN_NAME']) ? $row['COLUMN_NAME'] : current($row); } - $this->data_cache['field_names'][$table] = $retval; return $this->data_cache['field_names'][$table]; } @@ -901,14 +819,14 @@ class CI_DB_driver { /** * Determine if a particular field exists - * @access public + * * @param string * @param string - * @return boolean + * @return bool */ - function field_exists($field_name, $table_name) + public function field_exists($field_name, $table_name) { - return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE; + return in_array($field_name, $this->list_fields($table_name)); } // -------------------------------------------------------------------- @@ -916,23 +834,17 @@ class CI_DB_driver { /** * Returns an object with field data * - * @access public * @param string the table name - * @return object + * @return mixed */ - function field_data($table = '') + public function field_data($table = '') { if ($table == '') { - if ($this->db_debug) - { - return $this->display_error('db_field_param_missing'); - } - return FALSE; + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } $query = $this->query($this->_field_data($this->_protect_identifiers($table, TRUE, NULL, FALSE))); - return $query->field_data(); } @@ -941,15 +853,13 @@ class CI_DB_driver { /** * Generate an insert string * - * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @return string */ - function insert_string($table, $data) + public function insert_string($table, $data) { - $fields = array(); - $values = array(); + $fields = $values = array(); foreach ($data as $key => $val) { @@ -965,17 +875,16 @@ class CI_DB_driver { /** * Generate an update string * - * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @param mixed the "where" statement * @return string */ - function update_string($table, $data, $where) + public function update_string($table, $data, $where) { if ($where == '') { - return false; + return FALSE; } $fields = array(); @@ -993,7 +902,7 @@ class CI_DB_driver { $dest = array(); foreach ($where as $key => $val) { - $prefix = (count($dest) == 0) ? '' : ' AND '; + $prefix = (count($dest) === 0) ? '' : ' AND '; $key = $this->_protect_identifiers($key); if ($val !== '') @@ -1018,19 +927,12 @@ class CI_DB_driver { /** * Tests whether the string has an SQL operator * - * @access private * @param string * @return bool */ - function _has_operator($str) + protected function _has_operator($str) { - $str = trim($str); - if ( ! preg_match("/(\s|<|>|!|=|is null|is not null)/i", $str)) - { - return FALSE; - } - - return TRUE; + return (bool) preg_match('/(\s|<|>|!|=|is null|is not null)/i', trim($str)); } // -------------------------------------------------------------------- @@ -1038,12 +940,11 @@ class CI_DB_driver { /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * - * @access public * @param string the function name * @param mixed any parameters needed by the function * @return mixed */ - function call_function($function) + public function call_function($function) { $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_'; @@ -1054,25 +955,12 @@ class CI_DB_driver { if ( ! function_exists($function)) { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; } - else - { - $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null; - if (is_null($args)) - { - return call_user_func($function); - } - else - { - return call_user_func_array($function, $args); - } - } + return (func_num_args() > 1) + ? call_user_func_array($function, array_splice(func_get_args(), 1)) + : call_user_func($function); } // -------------------------------------------------------------------- @@ -1080,11 +968,10 @@ class CI_DB_driver { /** * Set Cache Directory Path * - * @access public * @param string the path to the cache directory * @return void */ - function cache_set_path($path = '') + public function cache_set_path($path = '') { $this->cachedir = $path; } @@ -1094,13 +981,11 @@ class CI_DB_driver { /** * Enable Query Caching * - * @access public - * @return void + * @return bool cache_on value */ - function cache_on() + public function cache_on() { - $this->cache_on = TRUE; - return TRUE; + return $this->cache_on = TRUE; } // -------------------------------------------------------------------- @@ -1108,13 +993,11 @@ class CI_DB_driver { /** * Disable Query Caching * - * @access public - * @return void + * @return bool cache_on value */ - function cache_off() + public function cache_off() { - $this->cache_on = FALSE; - return FALSE; + return $this->cache_on = FALSE; } @@ -1123,15 +1006,15 @@ class CI_DB_driver { /** * Delete the cache files associated with a particular URI * - * @access public - * @return void + * @return bool */ - function cache_delete($segment_one = '', $segment_two = '') + public function cache_delete($segment_one = '', $segment_two = '') { if ( ! $this->_cache_init()) { return FALSE; } + return $this->CACHE->delete($segment_one, $segment_two); } @@ -1140,10 +1023,9 @@ class CI_DB_driver { /** * Delete All cache files * - * @access public - * @return void + * @return bool */ - function cache_delete_all() + public function cache_delete_all() { if ( ! $this->_cache_init()) { @@ -1158,23 +1040,21 @@ class CI_DB_driver { /** * Initialize the Cache Class * - * @access private * @return void */ - function _cache_init() + protected function _cache_init() { - if (is_object($this->CACHE) AND class_exists('CI_DB_Cache')) + if (class_exists('CI_DB_Cache')) { - return TRUE; - } - - if ( ! class_exists('CI_DB_Cache')) - { - if ( ! @include(BASEPATH.'database/DB_cache.php')) + if (is_object($this->CACHE)) { - return $this->cache_off(); + return TRUE; } } + elseif ( ! @include_once(BASEPATH.'database/DB_cache.php')) + { + return $this->cache_off(); + } $this->CACHE = new CI_DB_Cache($this); // pass db object to support multiple db connections and returned db objects return TRUE; @@ -1185,16 +1065,15 @@ class CI_DB_driver { /** * Close DB Connection * - * @access public * @return void */ - function close() + public function close() { - if (is_resource($this->conn_id) OR is_object($this->conn_id)) + if ($this->conn_id) { $this->_close($this->conn_id); + $this->conn_id = FALSE; } - $this->conn_id = FALSE; } // -------------------------------------------------------------------- @@ -1202,13 +1081,12 @@ class CI_DB_driver { /** * Display an error message * - * @access public * @param string the error message * @param string any "swap" values - * @param boolean whether to localize the message + * @param bool whether to localize the message * @return string sends the application/error_db.php template */ - function display_error($error = '', $swap = '', $native = FALSE) + public function display_error($error = '', $swap = '', $native = FALSE) { $LANG =& load_class('Lang', 'core'); $LANG->load('db'); @@ -1227,9 +1105,7 @@ class CI_DB_driver { // Find the most likely culprit of the error by going through // the backtrace until the source file is no longer in the // database folder. - $trace = debug_backtrace(); - foreach ($trace as $call) { if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE) @@ -1237,7 +1113,6 @@ class CI_DB_driver { // Found it - use a relative path for safety $message[] = 'Filename: '.str_replace(array(BASEPATH, APPPATH), '', $call['file']); $message[] = 'Line Number: '.$call['line']; - break; } } @@ -1254,11 +1129,10 @@ class CI_DB_driver { * * This function adds backticks if appropriate based on db type * - * @access private * @param mixed the item to escape * @return mixed the item with backticks */ - function protect_identifiers($item, $prefix_single = FALSE) + public function protect_identifiers($item, $prefix_single = FALSE) { return $this->_protect_identifiers($item, $prefix_single); } @@ -1271,8 +1145,8 @@ class CI_DB_driver { * This function is used extensively by the Active Record class, and by * a couple functions in this class. * It takes a column or table name (optionally with an alias) and inserts - * the table prefix onto it. Some logic is necessary in order to deal with - * column names that include the path. Consider a query like this: + * the table prefix onto it. Some logic is necessary in order to deal with + * column names that include the path. Consider a query like this: * * SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table * @@ -1285,14 +1159,16 @@ class CI_DB_driver { * insert the table prefix (if it exists) in the proper position, and escape only * the correct identifiers. * - * @access private + * NOTE: This is used by DB_forge drivers and therefore needs to be public. + * (until a better solution is implemented) + * * @param string * @param bool * @param mixed * @param bool * @return string */ - function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) + public function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) { if ( ! is_bool($protect_identifiers)) { @@ -1302,7 +1178,6 @@ class CI_DB_driver { if (is_array($item)) { $escaped_array = array(); - foreach ($item as $k => $v) { $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v); @@ -1316,16 +1191,19 @@ class CI_DB_driver { // If the item has an alias declaration we remove it and set it aside. // Basically we remove everything to the right of the first space - $alias = ''; if (strpos($item, ' ') !== FALSE) { - $alias = strstr($item, " "); + $alias = strstr($item, ' '); $item = substr($item, 0, - strlen($alias)); } + else + { + $alias = ''; + } // This is basically a bug fix for queries that use MAX, MIN, etc. // If a parenthesis is found we know that we do not need to - // escape the data or add a prefix. There's probably a more graceful + // escape the data or add a prefix. There's probably a more graceful // way to deal with this, but I'm not thinking of it -- Rick if (strpos($item, '(') !== FALSE) { @@ -1340,7 +1218,7 @@ class CI_DB_driver { $parts = explode('.', $item); // Does the first segment of the exploded item match - // one of the aliases previously identified? If so, + // one of the aliases previously identified? If so, // we have nothing more to do other than escape the item if (in_array($parts[0], $this->ar_aliased_tables)) { @@ -1356,10 +1234,11 @@ class CI_DB_driver { $item = implode('.', $parts); } + return $item.$alias; } - // Is there a table prefix defined in the config file? If not, no need to do anything + // Is there a table prefix defined in the config file? If not, no need to do anything if ($this->dbprefix != '') { // We now add the table prefix based on some logic. @@ -1390,13 +1269,12 @@ class CI_DB_driver { } // Verify table prefix and replace if necessary - if ($this->swap_pre != '' && strncmp($parts[$i], $this->swap_pre, strlen($this->swap_pre)) === 0) + if ($this->swap_pre != '' && strpos($parts[$i], $this->swap_pre) === 0) { - $parts[$i] = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $parts[$i]); + $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]); } - // We only add the table prefix if it does not already exist - if (substr($parts[$i], 0, strlen($this->dbprefix)) != $this->dbprefix) + elseif (strpos($parts[$i], $this->dbprefix) !== 0) { $parts[$i] = $this->dbprefix.$parts[$i]; } @@ -1417,19 +1295,18 @@ class CI_DB_driver { if ($this->dbprefix != '') { // Verify table prefix and replace if necessary - if ($this->swap_pre != '' && strncmp($item, $this->swap_pre, strlen($this->swap_pre)) === 0) + if ($this->swap_pre != '' && strpos($item, $this->swap_pre) === 0) { - $item = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $item); + $item = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $item); } - // Do we prefix an item with no segments? - if ($prefix_single == TRUE AND substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix) + elseif ($prefix_single == TRUE && strpos($item, $this->dbprefix) !== 0) { $item = $this->dbprefix.$item; } } - if ($protect_identifiers === TRUE AND ! in_array($item, $this->_reserved_identifiers)) + if ($protect_identifiers === TRUE && ! in_array($item, $this->_reserved_identifiers)) { $item = $this->_escape_identifiers($item); } @@ -1440,6 +1317,5 @@ class CI_DB_driver { } - /* End of file DB_driver.php */ /* Location: ./system/database/DB_driver.php */ -- cgit v1.2.3-24-g4f1b From a5f2f694c6fb0cf3286a4ae44af47ac77684a36a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 25 Jan 2012 21:44:56 +0200 Subject: Pass CI_DB_driver::curs_id to CI_DB_oci8_result ... --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index d9d83d55d..117db68e8 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -395,7 +395,7 @@ class CI_DB_driver { if ($this->dbdriver === 'oci8') { $RES->stmt_id = $this->stmt_id; - $RES->curs_id = NULL; + $RES->curs_id = $this->curs_id; $RES->limit_used = $this->limit_used; $this->stmt_id = FALSE; } -- cgit v1.2.3-24-g4f1b From 12567e8263be2d007dc50fc94e7456c7183f8098 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 25 Jan 2012 22:50:33 +0200 Subject: Add better key/index detection for list_tables() and list_fields() --- system/database/DB_driver.php | 50 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 117db68e8..eb6ab7430 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -760,7 +760,30 @@ class CI_DB_driver { foreach ($query->result_array() as $row) { - $this->data_cache['table_names'][] = isset($row['TABLE_NAME']) ? $row['TABLE_NAME'] : array_shift($row); + // Do we know from which column to get the table name? + if ( ! isset($key)) + { + if (array_key_exists('table_name', $row)) + { + $key = 'table_name'; + } + elseif (array_key_exists('TABLE_NAME', $row)) + { + $key = 'TABLE_NAME'; + } + else + { + /* We have no other choice but to just get the first element's key. + * Due to array_shift() accepting it's argument by reference, if + * E_STRICT is on, this would trigger a warning. So we'll have to + * assign it first. + */ + $key = array_keys($row); + $key = array_shift($key); + } + } + + $this->data_cache['table_names'][] = $row[$key]; } return $this->data_cache['table_names']; @@ -809,7 +832,30 @@ class CI_DB_driver { foreach ($query->result_array() as $row) { - $this->data_cache['field_names'][$table][] = isset($row['COLUMN_NAME']) ? $row['COLUMN_NAME'] : current($row); + // Do we know from where to get the column's name? + if ( ! isset($key)) + { + if (array_key_exists('column_name', $row)) + { + $key = 'column_name'; + } + elseif (array_key_exists('COLUMN_NAME', $row)) + { + $key = 'COLUMN_NAME'; + } + else + { + /* We have no other choice but to just get the first element's key. + * Due to array_shift() accepting it's argument by reference, if + * E_STRICT is on, this would trigger a warning. So we'll have to + * assign it first. + */ + $key = array_keys($row); + $key = array_shift($key); + } + } + + $this->data_cache['field_names'][$table][] = $row[$key]; } return $this->data_cache['field_names'][$table]; -- cgit v1.2.3-24-g4f1b From 4a31568b2eb410dd153a3636da13d62e9cbfd41a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 02:03:10 +0200 Subject: DB forge escaping related --- system/database/drivers/oci8/oci8_driver.php | 2 +- system/database/drivers/oci8/oci8_forge.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 58d9b9ba3..9fce18674 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -568,7 +568,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param string * @return string */ - protected function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 35587a9cc..661ec3a40 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -97,7 +97,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field).' '.$attributes['TYPE'] + $sql .= "\n\t".$this->db->protect_identifiers($field).' '.$attributes['TYPE'] .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '') .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') @@ -113,7 +113,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')'; } @@ -123,11 +123,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tUNIQUE COLUMNS (".implode(', ', $key).')'; @@ -146,7 +146,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ public function _drop_table($table) { - return 'DROP TABLE '.$this->db->_protect_identifiers($table); + return 'DROP TABLE '.$this->db->protect_identifiers($table); } // -------------------------------------------------------------------- @@ -168,7 +168,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table).' '.$alter_type.' '.$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type === 'DROP') @@ -179,7 +179,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { return $sql.' '.$column_definition .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '') .($null === NULL ? ' NULL' : ' NOT NULL') - .($after_field != '' ? ' AFTER '.$this->db->_protect_identifiers($after_field) : ''); + .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } @@ -196,7 +196,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ public function _rename_table($table_name, $new_table_name) { - return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } -- cgit v1.2.3-24-g4f1b From cb9f361feb5f60191fc14a19f23aa0ba2bf91c37 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 02:06:48 +0200 Subject: DB forge escaping related --- system/database/drivers/sqlite3/sqlite3_driver.php | 12 ++++++------ system/database/drivers/sqlite3/sqlite3_forge.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index 2e6589b52..eb9a8f526 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -43,19 +43,19 @@ class CI_DB_sqlite3_driver extends CI_DB { public $dbdriver = 'sqlite3'; // The character used for escaping - public $_escape_char = '"'; + protected $_escape_char = '"'; // clause and character used for LIKE escape sequences - public $_like_escape_str = ' ESCAPE \'%s\' '; - public $_like_escape_chr = '!'; + protected $_like_escape_str = ' ESCAPE \'%s\' '; + 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. */ - public $_count_string = 'SELECT COUNT(*) AS '; - public $_random_keyword = ' RANDOM()'; + protected $_count_string = 'SELECT COUNT(*) AS '; + protected $_random_keyword = ' RANDOM()'; /** * Non-persistent database connection @@ -403,7 +403,7 @@ class CI_DB_sqlite3_driver extends CI_DB { * @param string * @return string */ - protected function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index a94970180..6398e48cd 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -111,7 +111,7 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field) + $sql .= "\n\t".$this->db->protect_identifiers($field) .' '.$attributes['TYPE'] .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '') .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') @@ -129,7 +129,7 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')'; } @@ -139,11 +139,11 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tUNIQUE (".implode(', ', $key).')'; @@ -195,7 +195,7 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { return FALSE; } - return 'ALTER TABLE '.$this->db->_protect_identifiers($table).' '.$alter_type.' '.$this->db->_protect_identifiers($column_name) + return 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name) .' '.$column_definition .($default_value != '' ? ' DEFAULT '.$default_value : '') // If NOT NULL is specified, the field must have a DEFAULT value other than NULL @@ -215,7 +215,7 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { */ public function _rename_table($table_name, $new_table_name) { - return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } -- cgit v1.2.3-24-g4f1b From f32110a952f8e1f58c4c0f13715681c248bc8ace Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 11:04:11 +0200 Subject: Fix a comment typo --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index eb6ab7430..113c3d3fe 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -74,7 +74,7 @@ class CI_DB_driver { protected $_protect_identifiers = TRUE; protected $_reserved_identifiers = array('*'); // Identifiers that should NOT be escaped - // These are use with Oracle + // These are used with Oracle public $stmt_id; public $curs_id; public $limit_used; -- cgit v1.2.3-24-g4f1b From 85facfa42793cce480d2f49696c2d3e3096763f0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 14:12:14 +0200 Subject: Replace array_key_exists() with isset() and ! empty() --- system/database/drivers/oci8/oci8_driver.php | 2 +- system/database/drivers/oci8/oci8_forge.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 9fce18674..700cde4b8 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -255,7 +255,7 @@ class CI_DB_oci8_driver extends CI_DB { { $sql .= $param['name'].','; - if (array_key_exists('type', $param) && ($param['type'] === OCI_B_CURSOR)) + if (isset($param['type']) && $param['type'] === OCI_B_CURSOR) { $have_cursor = TRUE; } diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 661ec3a40..1dcc346d2 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -98,10 +98,10 @@ class CI_DB_oci8_forge extends CI_DB_forge { $attributes = array_change_key_case($attributes, CASE_UPPER); $sql .= "\n\t".$this->db->protect_identifiers($field).' '.$attributes['TYPE'] - .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '') - .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') - .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') - .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL'); + .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '') + .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') + .(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') + .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL'); } // don't add a comma on the end of the last field -- cgit v1.2.3-24-g4f1b From 79f675446b29a0006ea090ed03ed721fb18c5dc5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 14:15:53 +0200 Subject: Replace array_key_exists() with isset() --- system/database/drivers/sqlite3/sqlite3_forge.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index 6398e48cd..43f08ed7a 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -113,11 +113,11 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { $sql .= "\n\t".$this->db->protect_identifiers($field) .' '.$attributes['TYPE'] - .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '') - .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') - .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') - .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') - .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : ''); + .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '') + .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') + .(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') + .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') + .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : ''); } // don't add a comma on the end of the last field -- cgit v1.2.3-24-g4f1b From fe3428ae6c3a563e2ada653e3d099231827c2c3d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 14:47:29 +0200 Subject: Another minor improvement --- system/database/drivers/sqlite3/sqlite3_forge.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index 43f08ed7a..68da7627e 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -113,11 +113,11 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { $sql .= "\n\t".$this->db->protect_identifiers($field) .' '.$attributes['TYPE'] - .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '') - .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') + .( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '') + .(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') .(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '') - .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') - .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : ''); + .(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') + .(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : ''); } // don't add a comma on the end of the last field -- cgit v1.2.3-24-g4f1b From a7c0656a530ca405d2ed18b8e9bd252975bb8505 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 27 Jan 2012 21:18:48 +0200 Subject: Removed a few more unnecessary lines --- system/database/DB_driver.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 03fc8a698..39eb1cc8a 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -180,12 +180,7 @@ class CI_DB_driver { else { // We've selected the DB. Now we set the character set - if ( ! $this->db_set_charset($this->char_set, $this->dbcollat)) - { - return FALSE; - } - - return TRUE; + return $this->db_set_charset($this->char_set, $this->dbcollat); } } @@ -247,9 +242,7 @@ class CI_DB_driver { // Some DBs have functions that return the version, and don't run special // SQL queries per se. In these instances, just return the result. - $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli'); - - if (in_array($this->dbdriver, $driver_version_exceptions)) + if (in_array($this->dbdriver, array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli')) { return $sql; } -- cgit v1.2.3-24-g4f1b From 0a9325c86cd5ccbdfe0c70ffb9bf816c8e15e148 Mon Sep 17 00:00:00 2001 From: Ross Duggan Date: Tue, 31 Jan 2012 15:47:52 +0000 Subject: HTTPS detection fix More closely follow the wording of the $_SERVER['HTTPS'] description in the PHP manual, which specifies a "non-empty" value rather than "non-null" --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Config.php b/system/core/Config.php index 66369115a..68417435d 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -80,7 +80,7 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; + $base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST'] . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } -- cgit v1.2.3-24-g4f1b From 98c347de9f62a3427170f9f73a692d159765e8cf Mon Sep 17 00:00:00 2001 From: Nick Busey Date: Thu, 2 Feb 2012 11:07:03 -0700 Subject: Adding equal to greater than, equal to less than form validators. --- system/language/english/form_validation_lang.php | 48 ++++++++++++------------ system/libraries/Form_validation.php | 38 ++++++++++++++++++- 2 files changed, 62 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 6afa37a29..2ee2cb9dd 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -25,29 +25,31 @@ * @filesource */ -$lang['required'] = "The %s field is required."; -$lang['isset'] = "The %s field must have a value."; -$lang['valid_email'] = "The %s field must contain a valid email address."; -$lang['valid_emails'] = "The %s field must contain all valid email addresses."; -$lang['valid_url'] = "The %s field must contain a valid URL."; -$lang['valid_ip'] = "The %s field must contain a valid IP."; -$lang['min_length'] = "The %s field must be at least %s characters in length."; -$lang['max_length'] = "The %s field cannot exceed %s characters in length."; -$lang['exact_length'] = "The %s field must be exactly %s characters in length."; -$lang['alpha'] = "The %s field may only contain alphabetical characters."; -$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters."; -$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes."; -$lang['numeric'] = "The %s field must contain only numbers."; -$lang['is_numeric'] = "The %s field must contain only numeric characters."; -$lang['integer'] = "The %s field must contain an integer."; -$lang['regex_match'] = "The %s field is not in the correct format."; -$lang['matches'] = "The %s field does not match the %s field."; -$lang['is_unique'] = "The %s field must contain a unique value."; -$lang['is_natural'] = "The %s field must contain only positive numbers."; -$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; -$lang['decimal'] = "The %s field must contain a decimal number."; -$lang['less_than'] = "The %s field must contain a number less than %s."; -$lang['greater_than'] = "The %s field must contain a number greater than %s."; +$lang['required'] = "The %s field is required."; +$lang['isset'] = "The %s field must have a value."; +$lang['valid_email'] = "The %s field must contain a valid email address."; +$lang['valid_emails'] = "The %s field must contain all valid email addresses."; +$lang['valid_url'] = "The %s field must contain a valid URL."; +$lang['valid_ip'] = "The %s field must contain a valid IP."; +$lang['min_length'] = "The %s field must be at least %s characters in length."; +$lang['max_length'] = "The %s field cannot exceed %s characters in length."; +$lang['exact_length'] = "The %s field must be exactly %s characters in length."; +$lang['alpha'] = "The %s field may only contain alphabetical characters."; +$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters."; +$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes."; +$lang['numeric'] = "The %s field must contain only numbers."; +$lang['is_numeric'] = "The %s field must contain only numeric characters."; +$lang['integer'] = "The %s field must contain an integer."; +$lang['regex_match'] = "The %s field is not in the correct format."; +$lang['matches'] = "The %s field does not match the %s field."; +$lang['is_unique'] = "The %s field must contain a unique value."; +$lang['is_natural'] = "The %s field must contain only positive numbers."; +$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; +$lang['decimal'] = "The %s field must contain a decimal number."; +$lang['less_than'] = "The %s field must contain a number less than %s."; +$lang['equal_to_less_than'] = "The %s field must contain a number equal to or less than %s."; +$lang['greater_than'] = "The %s field must contain a number greater than %s."; +$lang['equal_to_greater_than'] = "The %s field must contain a number equal to or greater than %s."; /* End of file form_validation_lang.php */ diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..1b2907a08 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1116,7 +1116,7 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** - * Greather than + * Greater than * * @param string * @return bool @@ -1130,6 +1130,24 @@ class CI_Form_validation { return $str > $min; } + // -------------------------------------------------------------------- + + /** + * Equal to or Greater than + * + * @access public + * @param string + * @return bool + */ + function equal_to_greater_than($str, $min) + { + if ( ! is_numeric($str)) + { + return FALSE; + } + return $str >= $min; + } + // -------------------------------------------------------------------- /** @@ -1149,6 +1167,24 @@ class CI_Form_validation { // -------------------------------------------------------------------- + /** + * Equal to or Less than + * + * @access public + * @param string + * @return bool + */ + function equal_to_less_than($str, $max) + { + if ( ! is_numeric($str)) + { + return FALSE; + } + return $str <= $max; + } + + // -------------------------------------------------------------------- + /** * Is a Natural number (0,1,2,3, etc.) * -- cgit v1.2.3-24-g4f1b From 6c308b7482375baa4982cce26219cecd20bafdc0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 2 Feb 2012 22:03:53 +0200 Subject: Fix some comment blocks --- system/libraries/Zip.php | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index e7c55de1b..174d18a67 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -67,7 +67,7 @@ class CI_Zip { */ public function add_dir($directory) { - foreach ((array)$directory as $dir) + foreach ( (array) $directory as $dir) { if ( ! preg_match('|.+/$|', $dir)) { @@ -82,17 +82,17 @@ class CI_Zip { // -------------------------------------------------------------------- /** - * Get file/directory modification time + * Get file/directory modification time * - * If this is a newly created file/dir, we will set the time to 'now' + * If this is a newly created file/dir, we will set the time to 'now' * - * @param string path to file - * @return array filemtime/filemdate + * @param string path to file + * @return array filemtime/filemdate */ protected function _get_mod_time($dir) { // filemtime() may return false, but raises an error for non-existing files - $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now); + $date = file_exists($dir) ? filemtime($dir) : getdate($this->now); return array( 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2, @@ -106,6 +106,8 @@ class CI_Zip { * Add Directory * * @param string the directory name + * @param int + * @param int * @return void */ protected function _add_dir($dir, $file_mtime, $file_mdate) @@ -184,6 +186,8 @@ class CI_Zip { * * @param string the file name/path * @param string the data to be encoded + * @param int + * @param int * @return void */ protected function _add_data($filepath, $data, $file_mtime, $file_mdate) @@ -233,6 +237,8 @@ class CI_Zip { /** * Read the contents of a file and add it to the zip * + * @param string + * @param bool * @return bool */ public function read_file($path, $preserve_filepath = FALSE) @@ -267,12 +273,13 @@ class CI_Zip { * is in the original file path will be recreated in the zip file. * * @param string path to source + * @param bool + * @param bool * @return bool */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { $path = rtrim($path, '/\\').'/'; - if ( ! $fp = @opendir($path)) { return FALSE; @@ -306,6 +313,8 @@ class CI_Zip { } } + closedir($fp); + return TRUE; } @@ -314,7 +323,7 @@ class CI_Zip { /** * Get the Zip file * - * @return string (binary encoded) + * @return string (binary encoded) */ public function get_zip() { @@ -325,12 +334,12 @@ class CI_Zip { } return $this->zipdata - . $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00" - . pack('v', $this->entries) // total # of entries "on this disk" - . pack('v', $this->entries) // total # of entries overall - . pack('V', strlen($this->directory)) // size of central dir - . pack('V', strlen($this->zipdata)) // offset to start of central dir - . "\x00\x00"; // .zip file comment length + .$this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00" + .pack('v', $this->entries) // total # of entries "on this disk" + .pack('v', $this->entries) // total # of entries overall + .pack('V', strlen($this->directory)) // size of central dir + .pack('V', strlen($this->zipdata)) // offset to start of central dir + ."\x00\x00"; // .zip file comment length } // -------------------------------------------------------------------- @@ -364,7 +373,6 @@ class CI_Zip { * Download * * @param string the file name - * @param string the data to be encoded * @return bool */ public function download($filename = 'backup.zip') -- cgit v1.2.3-24-g4f1b From d63e40138e675df40f3a17e04972e82e7a748307 Mon Sep 17 00:00:00 2001 From: Kevin Cupp Date: Sun, 5 Feb 2012 14:14:32 -0500 Subject: Adding in a few 503 status codes for common errors in response to this ExpressionEngine bug about errors getting cached by reverse proxies who cache 200 responses: http://expressionengine.com/bug_tracker/bug/17420 --- system/core/Common.php | 3 +++ system/core/Input.php | 1 + 2 files changed, 4 insertions(+) (limited to 'system') diff --git a/system/core/Common.php b/system/core/Common.php index 2f9c4ff43..225227d17 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -177,6 +177,7 @@ if ( ! function_exists('load_class')) { // Note: We use exit() rather then show_error() in order to avoid a // self-referencing loop with the Excptions class + set_status_header(503); exit('Unable to locate the specified class: '.$class.'.php'); } @@ -243,6 +244,7 @@ if ( ! function_exists('get_config')) // Fetch the config file if ( ! file_exists($file_path)) { + set_status_header(503); exit('The configuration file does not exist.'); } @@ -251,6 +253,7 @@ if ( ! function_exists('get_config')) // Does the $config array exist in the file? if ( ! isset($config) OR ! is_array($config)) { + set_status_header(503); exit('Your config file does not appear to be formatted correctly.'); } diff --git a/system/core/Input.php b/system/core/Input.php index 7a16e51ab..3339d97c5 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -592,6 +592,7 @@ class CI_Input { { if ( ! preg_match('/^[a-z0-9:_\/-]+$/i', $str)) { + set_status_header(503); exit('Disallowed Key Characters.'); } -- cgit v1.2.3-24-g4f1b From c1931667cbc614a704f536beb882931af82241cd Mon Sep 17 00:00:00 2001 From: Nick Busey Date: Mon, 6 Feb 2012 17:55:58 -0700 Subject: Renaming equal_to_greater_than to greater_than_equal_to, equal_to_less_than to less_than_equal_to --- system/language/english/form_validation_lang.php | 4 ++-- system/libraries/Form_validation.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 2ee2cb9dd..7fa6934f5 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -47,9 +47,9 @@ $lang['is_natural'] = "The %s field must contain only positive numbers."; $lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; $lang['decimal'] = "The %s field must contain a decimal number."; $lang['less_than'] = "The %s field must contain a number less than %s."; -$lang['equal_to_less_than'] = "The %s field must contain a number equal to or less than %s."; +$lang['less_than_equal_to'] = "The %s field must contain a number equal to or less than %s."; $lang['greater_than'] = "The %s field must contain a number greater than %s."; -$lang['equal_to_greater_than'] = "The %s field must contain a number equal to or greater than %s."; +$lang['greater_than_equal_to'] = "The %s field must contain a number equal to or greater than %s."; /* End of file form_validation_lang.php */ diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 1b2907a08..3ee3cf9df 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1139,7 +1139,7 @@ class CI_Form_validation { * @param string * @return bool */ - function equal_to_greater_than($str, $min) + function greater_than_equal_to($str, $min) { if ( ! is_numeric($str)) { @@ -1174,7 +1174,7 @@ class CI_Form_validation { * @param string * @return bool */ - function equal_to_less_than($str, $max) + function less_than_equal_to($str, $max) { if ( ! is_numeric($str)) { -- cgit v1.2.3-24-g4f1b From d5c0172e02b99278f4928897c1489cd628a50e2d Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Tue, 7 Feb 2012 19:06:46 -0500 Subject: Fix #1009 documentation fixed --- system/language/english/form_validation_lang.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 7fa6934f5..ea589618a 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -47,10 +47,10 @@ $lang['is_natural'] = "The %s field must contain only positive numbers."; $lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; $lang['decimal'] = "The %s field must contain a decimal number."; $lang['less_than'] = "The %s field must contain a number less than %s."; -$lang['less_than_equal_to'] = "The %s field must contain a number equal to or less than %s."; +$lang['less_than_equal_to'] = "The %s field must contain a number less than or equal to %s."; $lang['greater_than'] = "The %s field must contain a number greater than %s."; -$lang['greater_than_equal_to'] = "The %s field must contain a number equal to or greater than %s."; +$lang['greater_than_equal_to'] = "The %s field must contain a number greater than or equal to %s."; /* End of file form_validation_lang.php */ -/* Location: ./system/language/english/form_validation_lang.php */ \ No newline at end of file +/* Location: ./system/language/english/form_validation_lang.php */ -- cgit v1.2.3-24-g4f1b From 9448afb6da995098ce4ca2d24eb3d82b26434b4b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 8 Feb 2012 19:49:19 +0200 Subject: Fix CI_Input::is_ajax_request() --- system/core/Input.php | 66 ++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 3339d97c5..670f7a11f 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Input Class * @@ -152,7 +150,7 @@ class CI_Input { public function get($index = NULL, $xss_clean = FALSE) { // Check if a field has been provided - if ($index === NULL AND ! empty($_GET)) + if ($index === NULL && ! empty($_GET)) { $get = array(); @@ -179,7 +177,7 @@ class CI_Input { public function post($index = NULL, $xss_clean = FALSE) { // Check if a field has been provided - if ($index === NULL AND ! empty($_POST)) + if ($index === NULL && ! empty($_POST)) { $post = array(); @@ -206,9 +204,9 @@ class CI_Input { */ public function get_post($index = '', $xss_clean = FALSE) { - return ( ! isset($_POST[$index])) - ? $this->get($index, $xss_clean) - : $this->post($index, $xss_clean); + return isset($_POST[$index]) + ? $this->post($index, $xss_clean) + : $this->get($index, $xss_clean); } // -------------------------------------------------------------------- @@ -256,19 +254,19 @@ class CI_Input { } } - if ($prefix == '' AND config_item('cookie_prefix') != '') + if ($prefix == '' && config_item('cookie_prefix') != '') { $prefix = config_item('cookie_prefix'); } - if ($domain == '' AND config_item('cookie_domain') != '') + if ($domain == '' && config_item('cookie_domain') != '') { $domain = config_item('cookie_domain'); } - if ($path == '/' AND config_item('cookie_path') != '/') + if ($path == '/' && config_item('cookie_path') !== '/') { $path = config_item('cookie_path'); } - if ($secure == FALSE AND config_item('cookie_secure') != FALSE) + if ($secure == FALSE && config_item('cookie_secure') != FALSE) { $secure = config_item('cookie_secure'); } @@ -320,11 +318,11 @@ class CI_Input { $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; } - elseif ( ! $this->server('HTTP_CLIENT_IP') AND $this->server('REMOTE_ADDR')) + elseif ( ! $this->server('HTTP_CLIENT_IP') && $this->server('REMOTE_ADDR')) { $this->ip_address = $_SERVER['REMOTE_ADDR']; } - elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP')) + elseif ($this->server('REMOTE_ADDR') && $this->server('HTTP_CLIENT_IP')) { $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; } @@ -414,7 +412,7 @@ class CI_Input { return $this->user_agent; } - return $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT']; + return $this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : FALSE; } // -------------------------------------------------------------------- @@ -469,19 +467,16 @@ class CI_Input { { $_GET = array(); } - else + elseif (is_array($_GET) && count($_GET) > 0) { - if (is_array($_GET) AND count($_GET) > 0) + foreach ($_GET as $key => $val) { - foreach ($_GET as $key => $val) - { - $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); - } + $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); } } // Clean $_POST Data - if (is_array($_POST) AND count($_POST) > 0) + if (is_array($_POST) && count($_POST) > 0) { foreach ($_POST as $key => $val) { @@ -490,7 +485,7 @@ class CI_Input { } // Clean $_COOKIE Data - if (is_array($_COOKIE) AND count($_COOKIE) > 0) + if (is_array($_COOKIE) && count($_COOKIE) > 0) { // Also get rid of specially treated cookies that might be set by a server // or silly application, that are of no use to a CI application anyway @@ -568,7 +563,7 @@ class CI_Input { } // Standardize newlines if needed - if ($this->_standardize_newlines == TRUE AND strpos($str, "\r") !== FALSE) + if ($this->_standardize_newlines == TRUE && strpos($str, "\r") !== FALSE) { return str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); } @@ -625,7 +620,7 @@ class CI_Input { } else { - $headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE'); + $headers['Content-Type'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE'); foreach ($_SERVER as $key => $val) { @@ -655,9 +650,9 @@ class CI_Input { * * Returns the value of a single member of the headers class member * - * @param string array key for $this->headers - * @param boolean XSS Clean or not - * @return mixed FALSE on failure, string on success + * @param string array key for $this->headers + * @param bool XSS Clean or not + * @return mixed FALSE on failure, string on success */ public function get_request_header($index, $xss_clean = FALSE) { @@ -671,12 +666,9 @@ class CI_Input { return FALSE; } - if ($xss_clean === TRUE) - { - return $this->security->xss_clean($this->headers[$index]); - } - - return $this->headers[$index]; + return ($xss_clean === TRUE) + ? $this->security->xss_clean($this->headers[$index]) + : $this->headers[$index]; } // -------------------------------------------------------------------- @@ -686,11 +678,11 @@ class CI_Input { * * Test to see if a request contains the HTTP_X_REQUESTED_WITH header * - * @return boolean + * @return bool */ public function is_ajax_request() { - return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest'); + return ( ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'); } // -------------------------------------------------------------------- @@ -700,11 +692,11 @@ class CI_Input { * * Test to see if a request was made from the command line * - * @return boolean + * @return bool */ public function is_cli_request() { - return (php_sapi_name() === 'cli') or defined('STDIN'); + return (php_sapi_name() === 'cli' OR defined('STDIN')); } } -- cgit v1.2.3-24-g4f1b From 773e117f0bfd103116397d26f0ea1d1854de5ca8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 8 Feb 2012 23:02:19 +0200 Subject: Remove a few spaces --- system/core/Input.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 670f7a11f..ee15f4013 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -650,9 +650,9 @@ class CI_Input { * * Returns the value of a single member of the headers class member * - * @param string array key for $this->headers + * @param string array key for $this->headers * @param bool XSS Clean or not - * @return mixed FALSE on failure, string on success + * @return mixed FALSE on failure, string on success */ public function get_request_header($index, $xss_clean = FALSE) { -- cgit v1.2.3-24-g4f1b From 569091cf6ad7101059e6a4ffbd93f227aad9937f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Feb 2012 00:16:17 +0200 Subject: Revert CI_DB_driver changes (see #971) --- system/database/DB_driver.php | 287 +++++++++++++++++++++++++----------------- 1 file changed, 171 insertions(+), 116 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a30c8226d..daca08f0f 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1,13 +1,13 @@ -_db_set_charset($this->char_set, $this->dbcollat)) { @@ -222,9 +227,10 @@ class CI_DB_driver { /** * The name of the platform in use (mysql, mssql, etc...) * + * @access public * @return string */ - public function platform() + function platform() { return $this->dbdriver; } @@ -235,9 +241,10 @@ class CI_DB_driver { * Database Version Number. Returns a string containing the * version of the database being used * + * @access public * @return string */ - public function version() + function version() { if (FALSE === ($sql = $this->_version())) { @@ -274,11 +281,12 @@ class CI_DB_driver { * FALSE upon failure, and if the $db_debug variable is set to TRUE * will raise an error. * + * @access public * @param string An SQL query string * @param array An array of binding data * @return mixed */ - public function query($sql, $binds = FALSE, $return_object = TRUE) + function query($sql, $binds = FALSE, $return_object = TRUE) { if ($sql == '') { @@ -292,15 +300,15 @@ class CI_DB_driver { } // Verify table prefix and replace if necessary - if (($this->dbprefix != '' && $this->swap_pre != '') && ($this->dbprefix != $this->swap_pre)) + if ( ($this->dbprefix != '' AND $this->swap_pre != '') AND ($this->dbprefix != $this->swap_pre) ) { - $sql = preg_replace('/(\W)'.$this->swap_pre.'(\S+?)/', '\\1'.$this->dbprefix.'\\2', $sql); + $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql); } // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists - if ($this->cache_on == TRUE && stristr($sql, 'SELECT')) + if ($this->cache_on == TRUE AND stristr($sql, 'SELECT')) { if ($this->_cache_init()) { @@ -385,7 +393,7 @@ class CI_DB_driver { { // If caching is enabled we'll auto-cleanup any // existing files related to this particular URI - if ($this->cache_on == TRUE && $this->cache_autodel == TRUE && $this->_cache_init()) + if ($this->cache_on == TRUE AND $this->cache_autodel == TRUE AND $this->_cache_init()) { $this->CACHE->delete(); } @@ -404,10 +412,10 @@ class CI_DB_driver { // Load and instantiate the result driver $driver = $this->load_rdriver(); $RES = new $driver(); - $RES->conn_id = $this->conn_id; - $RES->result_id = $this->result_id; + $RES->conn_id = $this->conn_id; + $RES->result_id = $this->result_id; - if ($this->dbdriver == 'oci8') + if ($this->dbdriver === 'oci8') { $RES->stmt_id = $this->stmt_id; $RES->curs_id = $this->curs_id; @@ -419,7 +427,7 @@ class CI_DB_driver { // Is query caching enabled? If so, we'll serialize the // result object and save it to a cache file. - if ($this->cache_on == TRUE && $this->_cache_init()) + if ($this->cache_on == TRUE AND $this->_cache_init()) { // We'll create a new instance of the result object // only without the platform specific driver since @@ -447,9 +455,10 @@ class CI_DB_driver { /** * Load the result drivers * + * @access public * @return string the name of the result class */ - public function load_rdriver() + function load_rdriver() { $driver = 'CI_DB_'.$this->dbdriver.'_result'; @@ -470,10 +479,11 @@ class CI_DB_driver { * we only use it when running transaction commands since they do * not require all the features of the main query() function. * + * @access public * @param string the sql query * @return mixed */ - public function simple_query($sql) + function simple_query($sql) { if ( ! $this->conn_id) { @@ -489,9 +499,10 @@ class CI_DB_driver { * Disable Transactions * This permits transactions to be disabled at run-time. * + * @access public * @return void */ - public function trans_off() + function trans_off() { $this->trans_enabled = FALSE; } @@ -500,15 +511,15 @@ class CI_DB_driver { /** * Enable/disable Transaction Strict Mode - * * When strict mode is enabled, if you are running multiple groups of * transactions, if one group fails all groups will be rolled back. * If strict mode is disabled, each group is treated autonomously, meaning * a failure of one group will not affect any others * + * @access public * @return void */ - public function trans_strict($mode = TRUE) + function trans_strict($mode = TRUE) { $this->trans_strict = is_bool($mode) ? $mode : TRUE; } @@ -518,9 +529,10 @@ class CI_DB_driver { /** * Start Transaction * + * @access public * @return void */ - public function trans_start($test_mode = FALSE) + function trans_start($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -543,9 +555,10 @@ class CI_DB_driver { /** * Complete Transaction * + * @access public * @return bool */ - public function trans_complete() + function trans_complete() { if ( ! $this->trans_enabled) { @@ -589,9 +602,10 @@ class CI_DB_driver { /** * Lets you retrieve the transaction flag to determine if it has failed * + * @access public * @return bool */ - public function trans_status() + function trans_status() { return $this->_trans_status; } @@ -601,11 +615,12 @@ class CI_DB_driver { /** * Compile Bindings * + * @access public * @param string the sql statement * @param array an array of bind data * @return string */ - public function compile_binds($sql, $binds) + function compile_binds($sql, $binds) { if (strpos($sql, $this->bind_marker) === FALSE) { @@ -643,12 +658,17 @@ class CI_DB_driver { /** * Determines if a query is a "write" type. * + * @access public * @param string An SQL query string - * @return bool + * @return boolean */ - public function is_write_type($sql) + function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql); + if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql)) + { + return FALSE; + } + return TRUE; } // -------------------------------------------------------------------- @@ -656,10 +676,11 @@ class CI_DB_driver { /** * Calculate the aggregate query elapsed time * - * @param int The number of decimal places - * @return string + * @access public + * @param integer The number of decimal places + * @return integer */ - public function elapsed_time($decimals = 6) + function elapsed_time($decimals = 6) { return number_format($this->benchmark, $decimals); } @@ -669,9 +690,10 @@ class CI_DB_driver { /** * Returns the total number of queries * + * @access public * @return integer */ - public function total_queries() + function total_queries() { return $this->query_count; } @@ -681,9 +703,10 @@ class CI_DB_driver { /** * Returns the last query that was executed * + * @access public * @return void */ - public function last_query() + function last_query() { return end($this->queries); } @@ -696,10 +719,11 @@ class CI_DB_driver { * Escapes data based on type * Sets boolean and null types * + * @access public * @param string * @return mixed */ - public function escape($str) + function escape($str) { if (is_string($str)) { @@ -725,10 +749,11 @@ class CI_DB_driver { * Calls the individual driver for platform * specific escaping for LIKE conditions * + * @access public * @param string * @return mixed */ - public function escape_like_str($str) + function escape_like_str($str) { return $this->escape_str($str, TRUE); } @@ -738,13 +763,14 @@ class CI_DB_driver { /** * Primary * - * Retrieves the primary key. It assumes that the row in the first + * Retrieves the primary key. It assumes that the row in the first * position is the primary key * + * @access public * @param string the table name * @return string */ - public function primary($table = '') + function primary($table = '') { $fields = $this->list_fields($table); @@ -761,9 +787,10 @@ class CI_DB_driver { /** * Returns an array of table names * + * @access public * @return array */ - public function list_tables($constrain_by_prefix = FALSE) + function list_tables($constrain_by_prefix = FALSE) { // Is there a cached result? if (isset($this->data_cache['table_names'])) @@ -806,23 +833,24 @@ class CI_DB_driver { /** * Determine if a particular table exists - * + * @access public * @return boolean */ - public function table_exists($table_name) + function table_exists($table_name) { - return in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables()); + return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE; } // -------------------------------------------------------------------- /** - * Fetch Field Names + * Fetch MySQL Field Names * + * @access public * @param string the table name * @return array */ - public function list_fields($table = '') + function list_fields($table = '') { // Is there a cached result? if (isset($this->data_cache['field_names'][$table])) @@ -871,14 +899,14 @@ class CI_DB_driver { /** * Determine if a particular field exists - * + * @access public * @param string * @param string * @return boolean */ - public function field_exists($field_name, $table_name) + function field_exists($field_name, $table_name) { - return in_array($field_name, $this->list_fields($table_name)); + return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE; } // -------------------------------------------------------------------- @@ -886,10 +914,11 @@ class CI_DB_driver { /** * Returns an object with field data * + * @access public * @param string the table name * @return object */ - public function field_data($table = '') + function field_data($table = '') { if ($table == '') { @@ -901,6 +930,7 @@ class CI_DB_driver { } $query = $this->query($this->_field_data($this->_protect_identifiers($table, TRUE, NULL, FALSE))); + return $query->field_data(); } @@ -909,11 +939,12 @@ class CI_DB_driver { /** * Generate an insert string * + * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @return string */ - public function insert_string($table, $data) + function insert_string($table, $data) { $fields = array(); $values = array(); @@ -932,16 +963,17 @@ class CI_DB_driver { /** * Generate an update string * + * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @param mixed the "where" statement * @return string */ - public function update_string($table, $data, $where) + function update_string($table, $data, $where) { if ($where == '') { - return FALSE; + return false; } $fields = array(); @@ -984,12 +1016,19 @@ class CI_DB_driver { /** * Tests whether the string has an SQL operator * + * @access private * @param string * @return bool */ - protected function _has_operator($str) + function _has_operator($str) { - return (bool) preg_match('/(\s|<|>|!|=|is null|is not null)/i', trim($str)); + $str = trim($str); + if ( ! preg_match("/(\s|<|>|!|=|is null|is not null)/i", $str)) + { + return FALSE; + } + + return TRUE; } // -------------------------------------------------------------------- @@ -997,11 +1036,12 @@ class CI_DB_driver { /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * + * @access public * @param string the function name * @param mixed any parameters needed by the function * @return mixed */ - public function call_function($function) + function call_function($function) { $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_'; @@ -1038,10 +1078,11 @@ class CI_DB_driver { /** * Set Cache Directory Path * + * @access public * @param string the path to the cache directory * @return void */ - public function cache_set_path($path = '') + function cache_set_path($path = '') { $this->cachedir = $path; } @@ -1051,11 +1092,13 @@ class CI_DB_driver { /** * Enable Query Caching * + * @access public * @return void */ - public function cache_on() + function cache_on() { - return $this->cache_on = TRUE; + $this->cache_on = TRUE; + return TRUE; } // -------------------------------------------------------------------- @@ -1063,11 +1106,13 @@ class CI_DB_driver { /** * Disable Query Caching * + * @access public * @return void */ - public function cache_off() + function cache_off() { - return $this->cache_on = FALSE; + $this->cache_on = FALSE; + return FALSE; } @@ -1076,9 +1121,10 @@ class CI_DB_driver { /** * Delete the cache files associated with a particular URI * + * @access public * @return void */ - public function cache_delete($segment_one = '', $segment_two = '') + function cache_delete($segment_one = '', $segment_two = '') { if ( ! $this->_cache_init()) { @@ -1092,9 +1138,10 @@ class CI_DB_driver { /** * Delete All cache files * + * @access public * @return void */ - public function cache_delete_all() + function cache_delete_all() { if ( ! $this->_cache_init()) { @@ -1109,18 +1156,22 @@ class CI_DB_driver { /** * Initialize the Cache Class * + * @access private * @return void */ - private function _cache_init() + function _cache_init() { - if (is_object($this->CACHE) && class_exists('CI_DB_Cache')) + if (is_object($this->CACHE) AND class_exists('CI_DB_Cache')) { return TRUE; } - if ( ! class_exists('CI_DB_Cache') && ! @include(BASEPATH.'database/DB_cache.php')) + if ( ! class_exists('CI_DB_Cache')) { - return $this->cache_off(); + if ( ! @include(BASEPATH.'database/DB_cache.php')) + { + return $this->cache_off(); + } } $this->CACHE = new CI_DB_Cache($this); // pass db object to support multiple db connections and returned db objects @@ -1132,9 +1183,10 @@ class CI_DB_driver { /** * Close DB Connection * + * @access public * @return void */ - public function close() + function close() { if (is_resource($this->conn_id) OR is_object($this->conn_id)) { @@ -1148,12 +1200,13 @@ class CI_DB_driver { /** * Display an error message * + * @access public * @param string the error message * @param string any "swap" values * @param boolean whether to localize the message * @return string sends the application/error_db.php template */ - public function display_error($error = '', $swap = '', $native = FALSE) + function display_error($error = '', $swap = '', $native = FALSE) { $LANG =& load_class('Lang', 'core'); $LANG->load('db'); @@ -1199,10 +1252,11 @@ class CI_DB_driver { * * This function adds backticks if appropriate based on db type * + * @access private * @param mixed the item to escape * @return mixed the item with backticks */ - public function protect_identifiers($item, $prefix_single = FALSE) + function protect_identifiers($item, $prefix_single = FALSE) { return $this->_protect_identifiers($item, $prefix_single); } @@ -1216,7 +1270,7 @@ class CI_DB_driver { * a couple functions in this class. * It takes a column or table name (optionally with an alias) and inserts * the table prefix onto it. Some logic is necessary in order to deal with - * column names that include the path. Consider a query like this: + * column names that include the path. Consider a query like this: * * SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table * @@ -1229,14 +1283,14 @@ class CI_DB_driver { * insert the table prefix (if it exists) in the proper position, and escape only * the correct identifiers. * - * @access public (DB Forge needs it to be public!) + * @access private * @param string * @param bool * @param mixed * @param bool * @return string */ - public function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) + function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) { if ( ! is_bool($protect_identifiers)) { @@ -1284,7 +1338,7 @@ class CI_DB_driver { $parts = explode('.', $item); // Does the first segment of the exploded item match - // one of the aliases previously identified? If so, + // one of the aliases previously identified? If so, // we have nothing more to do other than escape the item if (in_array($parts[0], $this->ar_aliased_tables)) { @@ -1303,7 +1357,7 @@ class CI_DB_driver { return $item.$alias; } - // Is there a table prefix defined in the config file? If not, no need to do anything + // Is there a table prefix defined in the config file? If not, no need to do anything if ($this->dbprefix != '') { // We now add the table prefix based on some logic. @@ -1336,7 +1390,7 @@ class CI_DB_driver { // Verify table prefix and replace if necessary if ($this->swap_pre != '' && strncmp($parts[$i], $this->swap_pre, strlen($this->swap_pre)) === 0) { - $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]); + $parts[$i] = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $parts[$i]); } // We only add the table prefix if it does not already exist @@ -1357,23 +1411,23 @@ class CI_DB_driver { return $item.$alias; } - // Is there a table prefix? If not, no need to insert it + // Is there a table prefix? If not, no need to insert it if ($this->dbprefix != '') { // Verify table prefix and replace if necessary if ($this->swap_pre != '' && strncmp($item, $this->swap_pre, strlen($this->swap_pre)) === 0) { - $item = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $item); + $item = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $item); } // Do we prefix an item with no segments? - if ($prefix_single == TRUE && substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix) + if ($prefix_single == TRUE AND substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix) { $item = $this->dbprefix.$item; } } - if ($protect_identifiers === TRUE && ! in_array($item, $this->_reserved_identifiers)) + if ($protect_identifiers === TRUE AND ! in_array($item, $this->_reserved_identifiers)) { $item = $this->_escape_identifiers($item); } @@ -1384,5 +1438,6 @@ class CI_DB_driver { } + /* End of file DB_driver.php */ /* Location: ./system/database/DB_driver.php */ -- cgit v1.2.3-24-g4f1b From 1820933505d6aa8def25d0e74344f878c3ec76ad Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Thu, 9 Feb 2012 16:07:27 +0700 Subject: Fixed PDO --- system/database/DB.php | 1 + system/database/DB_driver.php | 27 ++- system/database/drivers/pdo/pdo_driver.php | 272 +++++++++++++++++++++-------- system/database/drivers/pdo/pdo_forge.php | 12 +- system/database/drivers/pdo/pdo_result.php | 67 ++++++- 5 files changed, 286 insertions(+), 93 deletions(-) (limited to 'system') diff --git a/system/database/DB.php b/system/database/DB.php index ed6afd7ed..d06ffb40e 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -82,6 +82,7 @@ function &DB($params = '', $active_record_override = NULL) $params = array( 'dbdriver' => $dns['scheme'], 'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '', + 'port' => (isset($dns['port'])) ? rawurldecode($dns['port']) : '', 'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '', 'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '', 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : '' diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 7445a5069..b829bbe46 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -81,8 +81,7 @@ class CI_DB_driver { var $stmt_id; var $curs_id; var $limit_used; - - + /** * Constructor. Accepts one parameter containing the database @@ -814,20 +813,23 @@ class CI_DB_driver { if ($query->num_rows() > 0) { - foreach ($query->result_array() as $row) + $table = FALSE; + $rows = $query->result_array(); + $key = (($row = current($rows)) && in_array('table_name', array_map('strtolower', array_keys($row)))); + + if ($key) { - if (isset($row['TABLE_NAME'])) - { - $retval[] = $row['TABLE_NAME']; - } - else - { - $retval[] = array_shift($row); - } + $table = array_key_exists('TABLE_NAME', $row) ? 'TABLE_NAME' : 'table_name'; + } + + foreach ($rows as $row) + { + $retval[] = ( ! $table) ? current($row) : $row[$table]; } } $this->data_cache['table_names'] = $retval; + return $this->data_cache['table_names']; } @@ -1436,10 +1438,7 @@ class CI_DB_driver { return $item.$alias; } - - } - /* End of file DB_driver.php */ /* Location: ./system/database/DB_driver.php */ diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 4f4f44ba7..e1602c4c5 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -46,9 +46,10 @@ class CI_DB_pdo_driver extends CI_DB { // the character used to excape - not necessary for PDO var $_escape_char = ''; + + // clause and character used for LIKE escape sequences var $_like_escape_str; var $_like_escape_chr; - /** * The syntax to count rows is slightly different across different @@ -57,29 +58,36 @@ class CI_DB_pdo_driver extends CI_DB { */ var $_count_string = "SELECT COUNT(*) AS "; var $_random_keyword; - + + // need to track the pdo DSN, driver and options + var $dsn; + var $pdodriver; var $options = array(); function __construct($params) { parent::__construct($params); - + + if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) == 2) + { + // If there is a minimum valid dsn string pattern found, we're done + // This for general PDO users, who tend to have full DSN string. + $this->pdodriver = end($match); + } + else + { + // Try to build a complete DSN string from params + $this->_connect_string($params); + } + // clause and character used for LIKE escape sequences - if (strpos($this->hostname, 'mysql') !== FALSE) + // this one depends on the driver being used + if ($this->pdodriver == 'mysql') { $this->_like_escape_str = ''; $this->_like_escape_chr = ''; - - //Prior to this version, the charset can't be set in the dsn - if(is_php('5.3.6')) - { - $this->hostname .= ";charset={$this->char_set}"; - } - - //Set the charset with the connection options - $this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}"; } - else if (strpos($this->hostname, 'odbc') !== FALSE) + elseif ($this->pdodriver == 'odbc') { $this->_like_escape_str = " {escape '%s'} "; $this->_like_escape_chr = '!'; @@ -90,14 +98,85 @@ class CI_DB_pdo_driver extends CI_DB { $this->_like_escape_chr = '!'; } - if (strpos($this->hostname, 'sqlite') === FALSE) + $this->trans_enabled = FALSE; + $this->_random_keyword = ' RND('.time().')'; // database specific random keyword + } + + /** + * Connection String + * + * @access private + * @param array + * @return void + */ + function _connect_string($params) + { + if (strpos($this->hostname, ':')) { - $this->hostname .= ";dbname=".$this->database; + // hostname generally would have this prototype + // $db['hostname'] = 'pdodriver:host(/Server(/DSN))=hostname(/DSN);'; + // We need to get the prefix (pdodriver used by PDO). + $this->dsn = $this->hostname; + $this->pdodriver = substr($this->hostname, 0, strpos($this->hostname, ':')); } - - $this->trans_enabled = FALSE; + else + { + // Invalid DSN, display an error + if ( ! array_key_exists('pdodriver', $params)) + { + show_error('Invalid DB Connection String for PDO'); + } - $this->_random_keyword = ' RND('.time().')'; // database specific random keyword + // Assuming that the following DSN string format is used: + // $dsn = 'pdo://username:password@hostname:port/database?pdodriver=pgsql'; + $this->dsn = $this->pdodriver.':'; + + // Add hostname to the DSN for databases that need it + if ( ! empty($this->hostname) && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid'))) + { + $this->dsn .= 'host='.$this->hostname.';'; + } + + // Add a port to the DSN for databases that can use it + if ( ! empty($this->port) && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'ibm', 'cubrid'))) + { + $this->dsn .= 'port='.$this->port.';'; + } + } + + // Add the database name to the DSN, if needed + if (stripos($this->dsn, 'dbname') === FALSE + && in_array($this->pdodriver, array('4D', 'pgsql', 'mysql', 'firebird', 'sybase', 'mssql', 'dblib', 'cubrid'))) + { + $this->dsn .= 'dbname='.$this->database.';'; + } + elseif (stripos($this->dsn, 'database') === FALSE && in_array($this->pdodriver, array('ibm', 'sqlsrv'))) + { + if (stripos($this->dsn, 'dsn') === FALSE) + { + $this->dsn .= 'database='.$this->database.';'; + } + } + elseif ($this->pdodriver === 'sqlite' && $this->dsn === 'sqlite:') + { + if ($this->database !== ':memory') + { + if ( ! file_exists($this->database)) + { + show_error('Invalid DB Connection string for PDO SQLite'); + } + + $this->dsn .= (strpos($this->database, DIRECTORY_SEPARATOR) !== 0) ? DIRECTORY_SEPARATOR : ''; + } + + $this->dsn .= $this->database; + } + + // Add charset to the DSN, if needed + if ( ! empty($this->char_set) && in_array($this->pdodriver, array('4D', 'mysql', 'sybase', 'mssql', 'dblib', 'oci'))) + { + $this->dsn .= 'charset='.$this->char_set.';'; + } } /** @@ -108,9 +187,9 @@ class CI_DB_pdo_driver extends CI_DB { */ function db_connect() { - $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT; - - return new PDO($this->hostname, $this->username, $this->password, $this->options); + $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; + + return $this->pdo_connect(); } // -------------------------------------------------------------------- @@ -123,10 +202,44 @@ class CI_DB_pdo_driver extends CI_DB { */ function db_pconnect() { - $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT; - $this->options['PDO::ATTR_PERSISTENT'] = TRUE; + $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; + $this->options[PDO::ATTR_PERSISTENT] = TRUE; - return new PDO($this->hostname, $this->username, $this->password, $this->options); + return $this->pdo_connect(); + } + + // -------------------------------------------------------------------- + + /** + * PDO connection + * + * @access private called by the PDO driver class + * @return resource + */ + function pdo_connect() + { + // Refer : http://ch2.php.net/manual/en/ref.pdo-mysql.connection.php + if ($this->pdodriver == 'mysql' && is_php('5.3.6')) + { + $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '$this->dbcollat'"; + } + + // Connecting... + try + { + $db = new PDO($this->dsn, $this->username, $this->password, $this->options); + } + catch (PDOException $e) + { + if ($this->db_debug && empty($this->failover)) + { + $this->display_error($e->getMessage(), '', TRUE); + } + + return FALSE; + } + + return $db; } // -------------------------------------------------------------------- @@ -146,6 +259,7 @@ class CI_DB_pdo_driver extends CI_DB { { return $this->db->display_error('db_unsuported_feature'); } + return FALSE; } @@ -175,7 +289,6 @@ class CI_DB_pdo_driver extends CI_DB { */ function db_set_charset($charset, $collation) { - // @todo - add support if needed return TRUE; } @@ -204,6 +317,7 @@ class CI_DB_pdo_driver extends CI_DB { function _execute($sql) { $sql = $this->_prep_query($sql); + $result_id = $this->conn_id->query($sql); if (is_object($result_id)) @@ -231,6 +345,17 @@ class CI_DB_pdo_driver extends CI_DB { */ function _prep_query($sql) { + if ($this->pdodriver === 'pgsql') + { + // Change the backtick(s) for Postgre + $sql = str_replace('`', '"', $sql); + } + elseif ($this->pdodriver === 'sqlite') + { + // Change the backtick(s) for SQLite + $sql = str_replace('`', '', $sql); + } + return $sql; } @@ -285,6 +410,7 @@ class CI_DB_pdo_driver extends CI_DB { } $ret = $this->conn->commit(); + return $ret; } @@ -310,6 +436,7 @@ class CI_DB_pdo_driver extends CI_DB { } $ret = $this->conn_id->rollBack(); + return $ret; } @@ -348,7 +475,9 @@ class CI_DB_pdo_driver extends CI_DB { if ($like === TRUE) { $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), + array($this->_like_escape_chr.'%', + $this->_like_escape_chr.'_', + $this->_like_escape_chr.$this->_like_escape_chr), $str); } @@ -378,9 +507,9 @@ class CI_DB_pdo_driver extends CI_DB { */ function insert_id($name=NULL) { - //Convenience method for postgres insertid - if (strpos($this->hostname, 'pgsql') !== FALSE) + if ($this->pdodriver == 'pgsql') { + //Convenience method for postgres insertid $v = $this->_version(); $table = func_num_args() > 0 ? func_get_arg(0) : NULL; @@ -389,8 +518,10 @@ class CI_DB_pdo_driver extends CI_DB { { $sql='SELECT LASTVAL() as ins_id'; } + $query = $this->query($sql); - $row = $query->row(); + $row = $query->row(); + return $row->ins_id; } else @@ -418,7 +549,9 @@ class CI_DB_pdo_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $sql = $this->_count_string.$this->_protect_identifiers('numrows').' FROM '; + $sql .= $this->_protect_identifiers($table, TRUE, NULL, FALSE); + $query = $this->query($sql); if ($query->num_rows() == 0) { @@ -427,6 +560,7 @@ class CI_DB_pdo_driver extends CI_DB { $row = $query->row(); $this->_reset_select(); + return (int) $row->numrows; } @@ -443,12 +577,19 @@ class CI_DB_pdo_driver extends CI_DB { */ function _list_tables($prefix_limit = FALSE) { - $sql = "SHOW TABLES FROM `".$this->database."`"; + if ($this->pdodriver == 'pgsql') + { + // Analog function to show all tables in postgre + $sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"; + } + else + { + $sql = "SHOW TABLES FROM `".$this->database."`"; + } if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); - return FALSE; // not currently supported + return FALSE; } return $sql; @@ -467,7 +608,7 @@ class CI_DB_pdo_driver extends CI_DB { */ function _list_columns($table = '') { - return "SHOW COLUMNS FROM ".$table; + return 'SHOW COLUMNS FROM '.$this->_from_tables($table); } // -------------------------------------------------------------------- @@ -483,7 +624,7 @@ class CI_DB_pdo_driver extends CI_DB { */ function _field_data($table) { - return "SELECT TOP 1 FROM ".$table; + return 'SELECT TOP 1 FROM '.$this->_from_tables($table); } // -------------------------------------------------------------------- @@ -497,6 +638,7 @@ class CI_DB_pdo_driver extends CI_DB { function _error_message() { $error_array = $this->conn_id->errorInfo(); + return $error_array[2]; } @@ -544,8 +686,8 @@ class CI_DB_pdo_driver extends CI_DB { if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; - + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item); + $str .= $this->_escape_char; } else { @@ -575,7 +717,7 @@ class CI_DB_pdo_driver extends CI_DB { $tables = array($tables); } - return (count($tables) == 1) ? $tables[0] : '('.implode(', ', $tables).')'; + return (count($tables) == 1) ? '`'.$tables[0].'`' : '('.implode(', ', $tables).')'; } // -------------------------------------------------------------------- @@ -593,7 +735,7 @@ class CI_DB_pdo_driver extends CI_DB { */ function _insert($table, $keys, $values) { - return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } // -------------------------------------------------------------------- @@ -611,7 +753,7 @@ class CI_DB_pdo_driver extends CI_DB { */ function _insert_batch($table, $keys, $values) { - return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); + return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES '.implode(', ', $values); } // -------------------------------------------------------------------- @@ -636,14 +778,11 @@ class CI_DB_pdo_driver extends CI_DB { $valstr[] = $key." = ".$val; } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - - $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - - $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); - - $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + $orderby = (count($orderby) >= 1) ? ' ORDER BY '.implode(', ', $orderby) : ''; + $sql = 'UPDATE '.$this->_from_tables($table).' SET '.implode(', ', $valstr); + $sql .= ($where != '' && count($where) >= 1) ? ' WHERE '.implode(' ', $where) : ''; $sql .= $orderby.$limit; return $sql; @@ -664,8 +803,8 @@ class CI_DB_pdo_driver extends CI_DB { */ function _update_batch($table, $values, $index, $where = NULL) { - $ids = array(); - $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; + $ids = array(); + $where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; foreach ($values as $key => $val) { @@ -680,12 +819,13 @@ class CI_DB_pdo_driver extends CI_DB { } } - $sql = "UPDATE ".$table." SET "; + $sql = 'UPDATE '.$this->_from_tables($table).' SET '; $cases = ''; foreach ($final as $k => $v) { $cases .= $k.' = CASE '."\n"; + foreach ($v as $row) { $cases .= $row."\n"; @@ -695,7 +835,6 @@ class CI_DB_pdo_driver extends CI_DB { } $sql .= substr($cases, 0, -2); - $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')'; return $sql; @@ -739,19 +878,20 @@ class CI_DB_pdo_driver extends CI_DB { if (count($where) > 0 OR count($like) > 0) { - $conditions = "\nWHERE "; + $conditions = "\nWHERE "; $conditions .= implode("\n", $this->ar_where); if (count($where) > 0 && count($like) > 0) { $conditions .= " AND "; } + $conditions .= implode("\n", $like); } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - return "DELETE FROM ".$table.$conditions.$limit; + return 'DELETE FROM '.$this->_from_tables($table).$conditions.$limit; } // -------------------------------------------------------------------- @@ -769,27 +909,16 @@ class CI_DB_pdo_driver extends CI_DB { */ function _limit($sql, $limit, $offset) { - if (strpos($this->hostname, 'cubrid') !== FALSE || strpos($this->hostname, 'sqlite') !== FALSE) + if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite') { - if ($offset == 0) - { - $offset = ''; - } - else - { - $offset .= ", "; - } + $offset = ($offset == 0) ? '' : $offset.', '; - return $sql."LIMIT ".$offset.$limit; + return $sql.'LIMIT '.$offset.$limit; } else { - $sql .= "LIMIT ".$limit; - - if ($offset > 0) - { - $sql .= " OFFSET ".$offset; - } + $sql .= 'LIMIT '.$limit; + $sql .= ($offset > 0) ? ' OFFSET '.$offset : ''; return $sql; } @@ -809,10 +938,7 @@ class CI_DB_pdo_driver extends CI_DB { $this->conn_id = null; } - } - - /* End of file pdo_driver.php */ /* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 076415928..478b2dbfb 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -96,7 +96,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { $sql .= 'IF NOT EXISTS '; } - $sql .= $this->db->_escape_identifiers($table)." ("; + $sql .= '`'.$this->db->_escape_identifiers($table).'` ('; $current_field_count = 0; foreach ($fields as $field=>$attributes) @@ -111,6 +111,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); + $numeric = array('SERIAL', 'INTEGER'); $sql .= "\n\t".$this->db->_protect_identifiers($field); @@ -118,7 +119,11 @@ class CI_DB_pdo_forge extends CI_DB_forge { if (array_key_exists('CONSTRAINT', $attributes)) { - $sql .= '('.$attributes['CONSTRAINT'].')'; + // Exception for Postgre numeric which not too happy with constraint within those type + if ( ! ($this->db->pdodriver == 'pgsql' && in_array($attributes['TYPE'], $numeric))) + { + $sql .= '('.$attributes['CONSTRAINT'].')'; + } } if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) @@ -219,7 +224,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE `'.$this->db->_protect_identifiers($table)."` $alter_type ".$this->db->_protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type == 'DROP') @@ -271,7 +276,6 @@ class CI_DB_pdo_forge extends CI_DB_forge { return $sql; } - } /* End of file pdo_forge.php */ diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 6b523b001..c333abc40 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -38,6 +38,16 @@ */ class CI_DB_pdo_result extends CI_DB_result { + /** + * @var bool Hold the flag whether a result handler already fetched before + */ + protected $is_fetched = FALSE; + + /** + * @var mixed Hold the fetched assoc array of a result handler + */ + protected $result_assoc; + /** * Number of rows in the result set * @@ -46,7 +56,59 @@ class CI_DB_pdo_result extends CI_DB_result { */ function num_rows() { - return $this->result_id->rowCount(); + if (empty($this->result_id) OR ! is_object($this->result_id)) + { + // invalid result handler + return 0; + } + elseif (($num_rows = $this->result_id->rowCount()) && $num_rows > 0) + { + // If rowCount return something, we're done. + return $num_rows; + } + + // Fetch the result, instead perform another extra query + return ($this->is_fetched && is_array($this->result_assoc)) ? count($this->result_assoc) : count($this->result_assoc()); + } + + /** + * Fetch the result handler + * + * @access public + * @return mixed + */ + function result_assoc() + { + // If the result already fetched before, use that one + if (count($this->result_array) > 0 OR $this->is_fetched) + { + return $this->result_array(); + } + + // Define the output + $output = array('assoc', 'object'); + + // Fetch the result + foreach ($output as $type) + { + // Define the method and handler + $res_method = '_fetch_'.$type; + $res_handler = 'result_'.$type; + + $this->$res_handler = array(); + $this->_data_seek(0); + + while ($row = $this->$res_method()) + { + $this->{$res_handler}[] = $row; + } + } + + // Save this as buffer and marked the fetch flag + $this->result_array = $this->result_assoc; + $this->is_fetched = TRUE; + + return $this->result_assoc; } // -------------------------------------------------------------------- @@ -78,6 +140,7 @@ class CI_DB_pdo_result extends CI_DB_result { { return $this->db->display_error('db_unsuported_feature'); } + return FALSE; } @@ -110,6 +173,7 @@ class CI_DB_pdo_result extends CI_DB_result { { return $this->db->display_error('db_unsuported_feature'); } + return FALSE; } } @@ -178,6 +242,5 @@ class CI_DB_pdo_result extends CI_DB_result { } - /* End of file pdo_result.php */ /* Location: ./system/database/drivers/pdo/pdo_result.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 62b8cae55d69775f09e3d64a6d35420c30241f98 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Thu, 9 Feb 2012 16:40:39 +0700 Subject: Change PHP.net mirror to the main mirror --- system/database/drivers/pdo/pdo_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index e1602c4c5..46b5e543d 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -218,10 +218,10 @@ class CI_DB_pdo_driver extends CI_DB { */ function pdo_connect() { - // Refer : http://ch2.php.net/manual/en/ref.pdo-mysql.connection.php + // Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php if ($this->pdodriver == 'mysql' && is_php('5.3.6')) { - $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '$this->dbcollat'"; + $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '.$this->dbcollat.'"; } // Connecting... -- cgit v1.2.3-24-g4f1b From 55bb97e6196f2d7f50a2d3f24968a94de3f64c87 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Thu, 9 Feb 2012 16:43:26 +0700 Subject: Typo --- system/database/drivers/pdo/pdo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 46b5e543d..9973bc007 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -221,7 +221,7 @@ class CI_DB_pdo_driver extends CI_DB { // Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php if ($this->pdodriver == 'mysql' && is_php('5.3.6')) { - $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '.$this->dbcollat.'"; + $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '$this->dbcollat'"; } // Connecting... -- cgit v1.2.3-24-g4f1b From fdd6ad088cd5c6f29974f23e1a2747c243ecb278 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 10 Feb 2012 13:10:27 +0700 Subject: Grammar correction --- system/database/drivers/pdo/pdo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 9973bc007..fc378daeb 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -71,7 +71,7 @@ class CI_DB_pdo_driver extends CI_DB { if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) == 2) { // If there is a minimum valid dsn string pattern found, we're done - // This for general PDO users, who tend to have full DSN string. + // This is for general PDO users, who tend to have a full DSN string. $this->pdodriver = end($match); } else -- cgit v1.2.3-24-g4f1b From 1c175c8d9697d6e8163770c45643f97e557149e6 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 10 Feb 2012 08:37:45 -0500 Subject: Fixed old-style pdo connection string --- system/database/drivers/pdo/pdo_driver.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index fc378daeb..5e5c01ef9 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -117,7 +117,11 @@ class CI_DB_pdo_driver extends CI_DB { // $db['hostname'] = 'pdodriver:host(/Server(/DSN))=hostname(/DSN);'; // We need to get the prefix (pdodriver used by PDO). $this->dsn = $this->hostname; - $this->pdodriver = substr($this->hostname, 0, strpos($this->hostname, ':')); + $split_dsn = explode(":", $this->hostname); + $this->pdodriver = $split_dsn[0]; + + // End this part of the dsn with a semicolon + $this->dsn .= rtrim(';', $this->dsn) . ';'; } else { -- cgit v1.2.3-24-g4f1b From 7d7b304bd98b310957d5077048899ea6e908583a Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 10 Feb 2012 09:11:59 -0500 Subject: Changed double quotes to single --- system/database/drivers/pdo/pdo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 5e5c01ef9..e84c1aaaf 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -117,7 +117,7 @@ class CI_DB_pdo_driver extends CI_DB { // $db['hostname'] = 'pdodriver:host(/Server(/DSN))=hostname(/DSN);'; // We need to get the prefix (pdodriver used by PDO). $this->dsn = $this->hostname; - $split_dsn = explode(":", $this->hostname); + $split_dsn = explode(':', $this->hostname); $this->pdodriver = $split_dsn[0]; // End this part of the dsn with a semicolon -- cgit v1.2.3-24-g4f1b From 574c85df35b68251c178510649b88b61eb84a43d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 12 Feb 2012 20:40:53 +0200 Subject: Improve custom_result_object() method --- system/database/drivers/oci8/oci8_result.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 7781b5bbd..ce6aa996f 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -306,7 +306,7 @@ class CI_DB_oci8_result extends CI_DB_result { */ public function custom_result_object($class_name) { - if (array_key_exists($class_name, $this->custom_result_object)) + if (isset($this->custom_result_object[$class_name])) { return $this->custom_result_object[$class_name]; } @@ -332,18 +332,17 @@ class CI_DB_oci8_result extends CI_DB_result { $data = &$this->result_object; } - $result_object = array(); + $this->custom_result_object[$class_name] = array(); for ($i = 0, $c = count($data); $i < $c; $i++) { - $result_object[$i] = new $class_name(); + $this->custom_result_object[$class_name][$i] = new $class_name(); foreach ($data[$i] as $key => $value) { - $result_object[$i]->$key = $value; + $this->custom_result_object[$class_name][$i]->$key = $value; } } - // Cache and return the array - return $this->custom_result_object[$class_name] = $result_object; + return $this->custom_result_object[$class_name]; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 74e5098bfb433b013bd4e3c95a23f5df43351469 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 12 Feb 2012 20:46:10 +0200 Subject: Replace a few spaces with a tab --- system/database/drivers/oci8/oci8_result.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index ce6aa996f..ff6f7a405 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -343,7 +343,7 @@ class CI_DB_oci8_result extends CI_DB_result { } return $this->custom_result_object[$class_name]; - } + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 9c2947a339f24e13aaf85f115bcea9f27fa10a83 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 13 Feb 2012 04:04:56 +0700 Subject: Fixed rtrim issue in hostname fragment, for backward compability --- system/database/drivers/pdo/pdo_driver.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index e84c1aaaf..2138ed665 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -117,11 +117,7 @@ class CI_DB_pdo_driver extends CI_DB { // $db['hostname'] = 'pdodriver:host(/Server(/DSN))=hostname(/DSN);'; // We need to get the prefix (pdodriver used by PDO). $this->dsn = $this->hostname; - $split_dsn = explode(':', $this->hostname); - $this->pdodriver = $split_dsn[0]; - - // End this part of the dsn with a semicolon - $this->dsn .= rtrim(';', $this->dsn) . ';'; + $this->pdodriver = current(explode(':', $this->hostname)); } else { @@ -179,6 +175,8 @@ class CI_DB_pdo_driver extends CI_DB { // Add charset to the DSN, if needed if ( ! empty($this->char_set) && in_array($this->pdodriver, array('4D', 'mysql', 'sybase', 'mssql', 'dblib', 'oci'))) { + // End dsn with a semicolon for extra backward compability + $this->dsn .= rtrim($this->dsn, ';').';'; $this->dsn .= 'charset='.$this->char_set.';'; } } -- cgit v1.2.3-24-g4f1b From dad61c273c1ce3553196883bf10633fcab868b17 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 13 Feb 2012 01:08:06 +0200 Subject: Add DSN string support --- system/database/drivers/oci8/oci8_driver.php | 87 +++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 700cde4b8..06acbbb67 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -78,6 +78,85 @@ class CI_DB_oci8_driver extends CI_DB { // throw off num_fields later public $limit_used; + public function __construct($params) + { + parent::__construct($params); + + $valid_dsns = array( + // Easy Connect string - Oracle 10g+ + 'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^/])?(\/[a-z0-9$_]+)?$/i', + 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS + 'in' => '/^[a-z0-9$_]+$/i' // Instance name (defined in tnsnames.ora) + ); + + /* Space characters don't have any effect when actually + * connecting, but can be a hassle while validating the DSN. + */ + $this->dsn = str_replace(array("\n", "\r", "\t", ' '), '', $this->dsn); + + if ($this->dsn !== '') + { + foreach ($valid_dsns as $regexp) + { + if (preg_match($regexp, $this->dsn)) + { + return; + } + } + } + + // Legacy support for TNS in the hostname configuration field + $this->hostname = str_replace(array("\n", "\r", "\t", ' '), '', $this->hostname); + if (preg_match($valid_dsns['tns'], $this->hostname)) + { + $this->dsn = $this->hostname; + return; + } + elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE + && (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== '')) + { + /* If the hostname field isn't empty, doesn't contain + * ':' and/or '/' and if port and/or database aren't + * empty, then the hostname field is most likely indeed + * just a hostname. Therefore we'll try and build an + * Easy Connect string from these 3 settings, assuming + * that the database field is a service name. + */ + $this->dsn = $this->hostname + .(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '') + .($this->database !== '' ? '/'.ltrim($this->database, '/') : ''); + + if (preg_match($valid_dsns['ec'], $this->dsn)) + { + return; + } + } + + /* At this point, we can only try and validate the hostname and + * database fields separately as DSNs. + */ + if (preg_match($valid_dsns['ec'], $this->hostname) OR preg_match($valid_dsns['in'], $this->hostname)) + { + $this->dsn = $this->hostname; + return; + } + + $this->database = str_replace(array("\n", "\r", "\t", ' '), '', $this->database); + foreach ($valid_dsns as $regexp) + { + if (preg_match($regexp, $this->database)) + { + return; + } + } + + /* Well - OK, an empty string should work as well. + * PHP will try to use environment variables to + * determine which Oracle instance to connect to. + */ + $this->dsn = ''; + } + /** * Non-persistent database connection * @@ -85,7 +164,9 @@ class CI_DB_oci8_driver extends CI_DB { */ public function db_connect() { - return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set); + return ( ! empty($this->char_set)) + ? @oci_connect($this->username, $this->password, $this->dsn, $this->char_set) + : @oci_connect($this->username, $this->password, $this->dsn); } // -------------------------------------------------------------------- @@ -97,7 +178,9 @@ class CI_DB_oci8_driver extends CI_DB { */ public function db_pconnect() { - return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set); + return ( ! empty($this->char_set)) + ? @oci_pconnect($this->username, $this->password, $this->dsn, $this->char_set) + : @oci_pconnect($this->username, $this->password, $this->dsn); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 45ba4f73a13660fa05f30d2ec21965620b0e5be5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 13 Feb 2012 01:24:39 +0200 Subject: Fix a possible bug in DB() and renamed a variable --- system/database/DB.php | 23 +++++++++++++---------- system/database/DB_driver.php | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'system') diff --git a/system/database/DB.php b/system/database/DB.php index d06ffb40e..8f9cb3743 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -74,24 +74,24 @@ function &DB($params = '', $active_record_override = NULL) * parameter. DSNs must have this prototype: * $dsn = 'driver://username:password@hostname/database'; */ - if (($dns = @parse_url($params)) === FALSE) + if (($dsn = @parse_url($params)) === FALSE) { show_error('Invalid DB Connection String'); } $params = array( - 'dbdriver' => $dns['scheme'], - 'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '', - 'port' => (isset($dns['port'])) ? rawurldecode($dns['port']) : '', - 'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '', - 'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '', - 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : '' + 'dbdriver' => $dsn['scheme'], + 'hostname' => (isset($dsn['host'])) ? rawurldecode($dsn['host']) : '', + 'port' => (isset($dsn['port'])) ? rawurldecode($dsn['port']) : '', + 'username' => (isset($dsn['user'])) ? rawurldecode($dsn['user']) : '', + 'password' => (isset($dsn['pass'])) ? rawurldecode($dsn['pass']) : '', + 'database' => (isset($dsn['path'])) ? rawurldecode(substr($dsn['path'], 1)) : '' ); // were additional config items set? - if (isset($dns['query'])) + if (isset($dsn['query'])) { - parse_str($dns['query'], $extra); + parse_str($dsn['query'], $extra); foreach ($extra as $key => $val) { // booleans please @@ -104,7 +104,10 @@ function &DB($params = '', $active_record_override = NULL) $val = FALSE; } - $params[$key] = $val; + if ( ! isset($params[$key])) + { + $params[$key] = $val; + } } } } diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index c4aa0beaf..30149193a 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -40,6 +40,7 @@ */ class CI_DB_driver { + public $dsn; public $username; public $password; public $hostname; -- cgit v1.2.3-24-g4f1b From fcd1f474a253cbe6e764a5c39cf5e58493670f60 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 13 Feb 2012 09:30:16 +0200 Subject: Fix Easy Connect string regexp and give TNS priority over it --- system/database/drivers/oci8/oci8_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 06acbbb67..3c70ccd9f 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -83,9 +83,9 @@ class CI_DB_oci8_driver extends CI_DB { parent::__construct($params); $valid_dsns = array( - // Easy Connect string - Oracle 10g+ - 'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^/])?(\/[a-z0-9$_]+)?$/i', 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS + // Easy Connect string (Oracle 10g+) + 'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i', 'in' => '/^[a-z0-9$_]+$/i' // Instance name (defined in tnsnames.ora) ); -- cgit v1.2.3-24-g4f1b From 8ad2ec7b0a8e6ea385b13ad2fd782fe775ef92db Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 13 Feb 2012 12:25:42 +0200 Subject: Fix issue #1036 --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 30149193a..a3171e395 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -627,7 +627,7 @@ class CI_DB_driver { */ public function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql); + return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 5dcdbc30649d8f8320953f3eb728a3eb5a7f7765 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 13 Feb 2012 21:15:56 +0700 Subject: Semicolon automatically added if not exists after hostname, if only database was not empty --- system/database/drivers/pdo/pdo_driver.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 2138ed665..5991586c7 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -118,6 +118,13 @@ class CI_DB_pdo_driver extends CI_DB { // We need to get the prefix (pdodriver used by PDO). $this->dsn = $this->hostname; $this->pdodriver = current(explode(':', $this->hostname)); + + // End dsn with a semicolon for extra backward compability + // if database property was not empty. + if ( ! empty($this->database)) + { + $this->dsn .= rtrim($this->dsn, ';').';'; + } } else { @@ -175,8 +182,6 @@ class CI_DB_pdo_driver extends CI_DB { // Add charset to the DSN, if needed if ( ! empty($this->char_set) && in_array($this->pdodriver, array('4D', 'mysql', 'sybase', 'mssql', 'dblib', 'oci'))) { - // End dsn with a semicolon for extra backward compability - $this->dsn .= rtrim($this->dsn, ';').';'; $this->dsn .= 'charset='.$this->char_set.';'; } } -- cgit v1.2.3-24-g4f1b From 928d83ce1590f14aadfa7a1805c00bb84bd9ef1c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 13 Feb 2012 14:07:57 -0500 Subject: Refixed Old-style pdo connection string --- system/database/drivers/pdo/pdo_driver.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 5991586c7..c5940ddc8 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -116,15 +116,12 @@ class CI_DB_pdo_driver extends CI_DB { // hostname generally would have this prototype // $db['hostname'] = 'pdodriver:host(/Server(/DSN))=hostname(/DSN);'; // We need to get the prefix (pdodriver used by PDO). - $this->dsn = $this->hostname; - $this->pdodriver = current(explode(':', $this->hostname)); + $dsnarray = explode(':', $this->hostname); + $this->pdodriver = $dsnarray[0]; // End dsn with a semicolon for extra backward compability // if database property was not empty. - if ( ! empty($this->database)) - { - $this->dsn .= rtrim($this->dsn, ';').';'; - } + $this->dsn .= rtrim($this->hostname, ';').';'; } else { @@ -139,7 +136,9 @@ class CI_DB_pdo_driver extends CI_DB { $this->dsn = $this->pdodriver.':'; // Add hostname to the DSN for databases that need it - if ( ! empty($this->hostname) && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid'))) + if ( ! empty($this->hostname) + && strpos($this->hostname, ':') === FALSE + && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid'))) { $this->dsn .= 'host='.$this->hostname.';'; } -- cgit v1.2.3-24-g4f1b From 25dc75595dd3550a6c20f3d34d8f5259465b545f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 13 Feb 2012 14:12:35 -0500 Subject: Re-added if ! empty clause --- system/database/drivers/pdo/pdo_driver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index c5940ddc8..8516cc6fe 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -121,7 +121,10 @@ class CI_DB_pdo_driver extends CI_DB { // End dsn with a semicolon for extra backward compability // if database property was not empty. - $this->dsn .= rtrim($this->hostname, ';').';'; + if( ! empty($this->database)) + { + $this->dsn .= rtrim($this->hostname, ';').';'; + } } else { -- cgit v1.2.3-24-g4f1b From f4524694418b0203e93c6b0ca1a9f28a9c6e4ba7 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 13 Feb 2012 14:13:28 -0500 Subject: Added missing space --- system/database/drivers/pdo/pdo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 8516cc6fe..de2b0abeb 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -121,7 +121,7 @@ class CI_DB_pdo_driver extends CI_DB { // End dsn with a semicolon for extra backward compability // if database property was not empty. - if( ! empty($this->database)) + if ( ! empty($this->database)) { $this->dsn .= rtrim($this->hostname, ';').';'; } -- cgit v1.2.3-24-g4f1b From 93cac5cc7bd1537788506d577c69852b4895a932 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 14 Feb 2012 14:45:02 +0200 Subject: Fix issue #1039 --- system/database/drivers/mysql/mysql_forge.php | 4 ++-- system/database/drivers/mysql/mysql_utility.php | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index d3107134e..0f251b086 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -147,7 +147,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { $sql .= 'IF NOT EXISTS '; } - $sql .= $this->db->_escape_identifiers($table).' ('.$this->_process_fields($fields); + $sql .= $this->db->protect_identifiers($table).' ('.$this->_process_fields($fields); if (count($primary_keys) > 0) { @@ -187,7 +187,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { */ public function _drop_table($table) { - return 'DROP TABLE IF EXISTS '.$this->db->_escape_identifiers($table); + return 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 0e7c18e16..538aaa0f7 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -56,7 +56,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { */ public function _optimize_table($table) { - return 'OPTIMIZE TABLE '.$this->db->_escape_identifiers($table); + return 'OPTIMIZE TABLE '.$this->db->protect_identifiers($table); } // -------------------------------------------------------------------- @@ -71,7 +71,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { */ public function _repair_table($table) { - return 'REPAIR TABLE '.$this->db->_escape_identifiers($table); + return 'REPAIR TABLE '.$this->db->protect_identifiers($table); } // -------------------------------------------------------------------- @@ -102,7 +102,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { } // Get the table schema - $query = $this->db->query('SHOW CREATE TABLE `'.$this->db->database.'`.`'.$table.'`'); + $query = $this->db->query('SHOW CREATE TABLE '.$this->db->protect_identifiers($this->db->database).'.'.$this->db->protect_identifiers($table)); // No result means the table name was invalid if ($query === FALSE) @@ -115,7 +115,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { if ($add_drop == TRUE) { - $output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline; + $output .= 'DROP TABLE IF EXISTS '.($this->db->protect_identifiers($table).';'.$newline.$newline; } $i = 0; @@ -135,7 +135,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { } // Grab all the data from the current table - $query = $this->db->query('SELECT * FROM '.$table); + $query = $this->db->query('SELECT * FROM '.$this->db->protect_identifiers($table)); if ($query->num_rows() == 0) { @@ -157,7 +157,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { TRUE); // Create a string of field names - $field_str .= '`'.$field->name.'`, '; + $field_str .= $this->db->protect_identifiers($field->name).', '; $i++; } @@ -192,7 +192,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { $val_str = preg_replace('/, $/' , '', $val_str); // Build the INSERT string - $output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline; + $output .= 'INSERT INTO '.$this->db->protect_identifiers($table).' ('.$field_str.') VALUES ('.$val_str.');'.$newline; } return $output.$newline.$newline; @@ -200,6 +200,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { return $output; } + } /* End of file mysql_utility.php */ -- cgit v1.2.3-24-g4f1b From c51816da79d4b7a1c517142d7380234a9d8bae77 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 14 Feb 2012 16:55:42 +0200 Subject: Fix another issue --- system/database/drivers/mysql/mysql_utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 538aaa0f7..9d7cb679c 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -195,7 +195,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { $output .= 'INSERT INTO '.$this->db->protect_identifiers($table).' ('.$field_str.') VALUES ('.$val_str.');'.$newline; } - return $output.$newline.$newline; + $output .= $newline.$newline; } return $output; -- cgit v1.2.3-24-g4f1b From 76e0435af10579afdc3ed4956aeafa83a17decd3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 11:55:17 -0500 Subject: First iteration of interbase driver --- system/database/drivers/interbase/index.html | 10 + .../drivers/interbase/interbase_driver.php | 676 +++++++++++++++++++++ .../database/drivers/interbase/interbase_forge.php | 262 ++++++++ .../drivers/interbase/interbase_result.php | 190 ++++++ .../drivers/interbase/interbase_utility.php | 108 ++++ 5 files changed, 1246 insertions(+) create mode 100644 system/database/drivers/interbase/index.html create mode 100644 system/database/drivers/interbase/interbase_driver.php create mode 100644 system/database/drivers/interbase/interbase_forge.php create mode 100644 system/database/drivers/interbase/interbase_result.php create mode 100644 system/database/drivers/interbase/interbase_utility.php (limited to 'system') diff --git a/system/database/drivers/interbase/index.html b/system/database/drivers/interbase/index.html new file mode 100644 index 000000000..c942a79ce --- /dev/null +++ b/system/database/drivers/interbase/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php new file mode 100644 index 000000000..bc9cb8f08 --- /dev/null +++ b/system/database/drivers/interbase/interbase_driver.php @@ -0,0 +1,676 @@ +database, $this->username, $this->password, $this->charset)) + { + log_message('error', $error); + + if ($this->db_debug) + { + $this->display_error($error, '', TRUE); + } + + return FALSE; + } + + return $conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Persistent database connection + * + * @access private called by the base class + * @return resource + */ + function db_pconnect() + { + if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->charset)) + { + log_message('error', $error); + + if ($this->db_debug) + { + $this->display_error($error, '', TRUE); + } + + return FALSE; + } + + return $conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @access public + * @return void + */ + function reconnect() + { + // not implemented in Interbase/Firebird + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @access private called by the base class + * @return resource + */ + function db_select() + { + // Connection selects the database + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @access public + * @param string + * @param string + * @return resource + */ + function db_set_charset($charset, $collation) + { + // @todo - add support if needed + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @access public + * @return string + */ + function _version() + { + //@todo - add support if needed + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @access private called by the base class + * @param string an SQL query + * @return resource + */ + function _execute($sql) + { + $sql = $this->_prep_query($sql); + return @ibase_query($this->conn_id, $sql); + } + + // -------------------------------------------------------------------- + + /** + * Prep the query + * + * If needed, each database adapter can prep the query string + * + * @access private called by execute() + * @param string an SQL query + * @return string + */ + function _prep_query($sql) + { + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @access public + * @return bool + */ + function trans_begin($test_mode = FALSE) + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + + $this->trans = @ibase_trans($this->conn_id); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @access public + * @return bool + */ + function trans_commit() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + @ibase_commit($this->trans); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @access public + * @return bool + */ + function trans_rollback() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + @ibase_rollback($this->trans); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Escape String + * + * @access public + * @param string + * @param bool whether or not the string will be used in a LIKE condition + * @return string + */ + function escape_str($str, $like = FALSE) + { + if (is_array($str)) + { + foreach ($str as $key => $val) + { + $str[$key] = $this->escape_str($val, $like); + } + + return $str; + } + + // escape LIKE condition wildcards + if ($like === TRUE) + { + $str = str_replace( array('%', '_', $this->_like_escape_chr), + array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), + $str); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @access public + * @return integer + */ + function affected_rows() + { + return @ibase_affected_rows($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @access public + * @return integer + */ + function insert_id() + { + //@todo Implement manually + return 0; + } + + // -------------------------------------------------------------------- + + /** + * "Count All" query + * + * Generates a platform-specific query string that counts all records in + * the specified database + * + * @access public + * @param string + * @return string + */ + function count_all($table = '') + { + if ($table == '') + { + return 0; + } + + $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + + if ($query->num_rows() == 0) + { + return 0; + } + + $row = $query->row(); + $this->_reset_select(); + return (int) $row->numrows; + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @access private + * @param boolean + * @return string + */ + function _list_tables($prefix_limit = FALSE) + { + $sql = <<dbprefix != '') + { + $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @access public + * @param string the table name + * @return string + */ + function _list_columns($table = '') + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Field data query + * + * Generates a platform-specific query so that the column data can be retrieved + * + * @access public + * @param string the table name + * @return object + */ + function _field_data($table) + { + return "SELECT * FROM ".$table." LIMIT 1"; + } + + // -------------------------------------------------------------------- + + /** + * The error message string + * + * @access private + * @return string + */ + function _error_message() + { + return ibase_errmsg(); + } + + // -------------------------------------------------------------------- + + /** + * The error message number + * + * @access private + * @return integer + */ + function _error_number() + { + return ibase_errcode(); + } + + // -------------------------------------------------------------------- + + /** + * Escape the SQL Identifiers + * + * This function escapes column and table names + * + * @access private + * @param string + * @return string + */ + function _escape_identifiers($item) + { + foreach ($this->_reserved_identifiers as $id) + { + if (strpos($item, '.'.$id) !== FALSE) + { + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + } + } + + if (strpos($item, '.') !== FALSE) + { + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + } + else + { + $str = $this->_escape_char.$item.$this->_escape_char; + } + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + } + + // -------------------------------------------------------------------- + + /** + * From Tables + * + * This function implicitly groups FROM tables so there is no confusion + * about operator precedence in harmony with SQL standards + * + * @access public + * @param type + * @return type + */ + function _from_tables($tables) + { + if ( ! is_array($tables)) + { + $tables = array($tables); + } + + return '('.implode(', ', $tables).')'; + } + + // -------------------------------------------------------------------- + + /** + * Insert statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert($table, $keys, $values) + { + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @param array the orderby clause + * @param array the limit clause + * @return string + */ + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + { + foreach ($values as $key => $val) + { + $valstr[] = $key." = ".$val; + } + + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; + + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); + + $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + + $sql .= $orderby.$limit; + + return $sql; + } + + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * If the database does not support the truncate() command + * This function maps to "DELETE FROM table" + * + * @access public + * @param string the table name + * @return string + */ + function _truncate($table) + { + return $this->_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @access public + * @param string the table name + * @param array the where clause + * @param string the limit clause + * @return string + */ + function _delete($table, $where = array(), $like = array(), $limit = FALSE) + { + $conditions = ''; + + if (count($where) > 0 OR count($like) > 0) + { + $conditions = "\nWHERE "; + $conditions .= implode("\n", $this->ar_where); + + if (count($where) > 0 && count($like) > 0) + { + $conditions .= " AND "; + } + $conditions .= implode("\n", $like); + } + + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + + return "DELETE FROM ".$table.$conditions.$limit; + } + + // -------------------------------------------------------------------- + + /** + * Limit string + * + * Generates a platform-specific LIMIT clause + * + * @access public + * @param string the sql query string + * @param integer the number of rows to limit the query to + * @param integer the offset value + * @return string + */ + function _limit($sql, $limit, $offset) + { + if ($offset == 0) + { + $offset = ''; + } + else + { + $offset .= ", "; + } + + return $sql."LIMIT ".$offset.$limit; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @access public + * @param resource + * @return void + */ + function _close($conn_id) + { + @ibase_close($conn_id); + } + + +} + + +/* End of file interbase_driver.php */ +/* Location: ./system/database/drivers/interbase/interbase_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php new file mode 100644 index 000000000..36d980b67 --- /dev/null +++ b/system/database/drivers/interbase/interbase_forge.php @@ -0,0 +1,262 @@ +conn_id); + } + // -------------------------------------------------------------------- + + /** + * Create Table + * + * @access private + * @param string the table name + * @param array the fields + * @param mixed primary key(s) + * @param mixed key(s) + * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @return bool + */ + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + { + $sql = 'CREATE TABLE '; + + $sql .= $this->db->_escape_identifiers($table)."("; + $current_field_count = 0; + + foreach ($fields as $field=>$attributes) + { + // Numeric field names aren't allowed in databases, so if the key is + // numeric, we know it was assigned by PHP and the developer manually + // entered the field information, so we'll simply add it to the list + if (is_numeric($field)) + { + $sql .= "\n\t$attributes"; + } + else + { + $attributes = array_change_key_case($attributes, CASE_UPPER); + + $sql .= "\n\t".$this->db->_protect_identifiers($field); + + $sql .= ' '.$attributes['TYPE']; + + if (array_key_exists('CONSTRAINT', $attributes)) + { + $sql .= '('.$attributes['CONSTRAINT'].')'; + } + + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) + { + $sql .= ' UNSIGNED'; + } + + if (array_key_exists('DEFAULT', $attributes)) + { + $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; + } + + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) + { + $sql .= ' NULL'; + } + else + { + $sql .= ' NOT NULL'; + } + + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) + { + $sql .= ' AUTO_INCREMENT'; + } + } + + // don't add a comma on the end of the last field + if (++$current_field_count < count($fields)) + { + $sql .= ','; + } + } + + if (count($primary_keys) > 0) + { + $primary_keys = $this->db->_protect_identifiers($primary_keys); + $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; + } + + if (is_array($keys) && count($keys) > 0) + { + foreach ($keys as $key) + { + if (is_array($key)) + { + $key = $this->db->_protect_identifiers($key); + } + else + { + $key = array($this->db->_protect_identifiers($key)); + } + + $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")"; + } + } + + $sql .= "\n)"; + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Drop Table + * + * @access private + * @return bool + */ + function _drop_table($table) + { + if ($this->db->db_debug) + { + return $this->db->display_error('db_unsuported_feature'); + } + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Alter table query + * + * Generates a platform-specific query so that a table can be altered + * Called by add_column(), drop_column(), and column_alter(), + * + * @access private + * @param string the ALTER type (ADD, DROP, CHANGE) + * @param string the column name + * @param string the table name + * @param string the column definition + * @param string the default value + * @param boolean should 'NOT NULL' be added + * @param string the field after which we should add the new field + * @return object + */ + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + { + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + + // DROP has everything it needs now. + /*if ($alter_type == 'DROP') + { + // SQLite does not support dropping columns + // http://www.sqlite.org/omitted.html + // http://www.sqlite.org/faq.html#q11 + return FALSE; + }*/ + + $sql .= " $column_definition"; + + if ($default_value != '') + { + $sql .= " DEFAULT \"$default_value\""; + } + + if ($null === NULL) + { + $sql .= ' NULL'; + } + else + { + $sql .= ' NOT NULL'; + } + + if ($after_field != '') + { + $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + } + + return $sql; + + } + + // -------------------------------------------------------------------- + + /** + * Rename a table + * + * Generates a platform-specific query so that a table can be renamed + * + * @access private + * @param string the old table name + * @param string the new table name + * @return string + */ + function _rename_table($table_name, $new_table_name) + { + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); + return $sql; + } +} + +/* End of file interbase_forge.php */ +/* Location: ./system/database/drivers/interbase/interbase_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php new file mode 100644 index 000000000..d811fc608 --- /dev/null +++ b/system/database/drivers/interbase/interbase_result.php @@ -0,0 +1,190 @@ +result_id)) + { + $count++; + } + + return $count; + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @access public + * @return integer + */ + function num_fields() + { + return @ibase_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @access public + * @return array + */ + function list_fields() + { + $field_names = array(); + for ($i = 0; $i < $this->num_fields(); $i++) + { + $info = ibase_field_info($this->result_id, $i); + $field_names[] = $info['name']; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @access public + * @return array + */ + function field_data() + { + + $retval = array(); + for ($i = 0; $i < $this->num_fields(); $i++) + { + $info = ibase_field_info($this->result_id, $i); + + $F = new stdClass(); + $F->name = $info['name']; + $F->type = $info['type']; + $F->max_length = $info['length']; + $F->primary_key = 0; + $F->default = ''; + + $retval[] = $F; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return null + */ + function free_result() + { + @ibase_free_result($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero + * + * @access private + * @return array + */ + function _data_seek($n = 0) + { + //Interbase driver doesn't implement a sutable function + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @access private + * @return array + */ + function _fetch_assoc() + { + return @ibase_fetch_assoc($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @access private + * @return object + */ + function _fetch_object() + { + return @ibase_fetch_object($this->result_id); + } + +} + + +/* End of file interbase_result.php */ +/* Location: ./system/database/drivers/interbase/interbase_result.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php new file mode 100644 index 000000000..533a269b2 --- /dev/null +++ b/system/database/drivers/interbase/interbase_utility.php @@ -0,0 +1,108 @@ +db_debug) + { + return $this->db->display_error('db_unsuported_feature'); + } + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Optimize table query + * + * Is optimization even supported in Interbase/Firebird? + * + * @access private + * @param string the table name + * @return object + */ + function _optimize_table($table) + { + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Repair table query + * + * Table repairs are not supported in Interbase/Firebird + * + * @access private + * @param string the table name + * @return object + */ + function _repair_table($table) + { + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Interbase/Firebird Export + * + * @access private + * @param array Preferences + * @return mixed + */ + function _backup($params = array()) + { + // Currently unsupported + return $this->db->display_error('db_unsuported_feature'); + } +} + +/* End of file interbase_utility.php */ +/* Location: ./system/database/drivers/interbase/interbase_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4be822bcca94273967abf010ef67f64ead5e6bf2 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 12:07:34 -0500 Subject: Added public declarations --- .../drivers/interbase/interbase_driver.php | 62 +++++++++++----------- .../database/drivers/interbase/interbase_forge.php | 12 ++--- .../drivers/interbase/interbase_result.php | 16 +++--- .../drivers/interbase/interbase_utility.php | 8 +-- 4 files changed, 49 insertions(+), 49 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index bc9cb8f08..671b128ea 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -70,7 +70,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_connect() + public function db_connect() { if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->charset)) { @@ -95,7 +95,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->charset)) { @@ -123,7 +123,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in Interbase/Firebird } @@ -136,7 +136,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { // Connection selects the database return TRUE; @@ -152,7 +152,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string * @return resource */ - function db_set_charset($charset, $collation) + public function db_set_charset($charset, $collation) { // @todo - add support if needed return TRUE; @@ -166,7 +166,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return string */ - function _version() + public function _version() { //@todo - add support if needed return TRUE; @@ -181,7 +181,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return resource */ - function _execute($sql) + public function _execute($sql) { $sql = $this->_prep_query($sql); return @ibase_query($this->conn_id, $sql); @@ -198,7 +198,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return string */ - function _prep_query($sql) + public function _prep_query($sql) { return $sql; } @@ -211,7 +211,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -242,7 +242,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -268,7 +268,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -296,7 +296,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -327,7 +327,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return @ibase_affected_rows($this->conn_id); } @@ -340,7 +340,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return integer */ - function insert_id() + public function insert_id() { //@todo Implement manually return 0; @@ -358,7 +358,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -388,7 +388,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + public function _list_tables($prefix_limit = FALSE) { $sql = <<_reserved_identifiers as $id) { @@ -504,14 +504,14 @@ SQL; /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -534,7 +534,7 @@ SQL; * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -554,7 +554,7 @@ SQL; * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -582,13 +582,13 @@ SQL; * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return $this->_delete($table); } @@ -606,7 +606,7 @@ SQL; * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -640,7 +640,7 @@ SQL; * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -663,7 +663,7 @@ SQL; * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @ibase_close($conn_id); } diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 36d980b67..815107d85 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -43,7 +43,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the database name * @return bool */ - function _create_database() + public function _create_database() { // In Interbase/Firebird, a database is created when you connect to the database. // We'll return TRUE so that an error isn't generated @@ -60,7 +60,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * - the current db is dropped * @return bool */ - function _drop_database($name='') + public function _drop_database($name='') { return ibase_drop_db($this->conn_id); } @@ -77,7 +77,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -174,7 +174,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @access private * @return bool */ - function _drop_table($table) + public function _drop_table($table) { if ($this->db->db_debug) { @@ -201,7 +201,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); @@ -251,7 +251,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); return $sql; diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index d811fc608..9d827895d 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -44,7 +44,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return integer */ - function num_rows() + public function num_rows() { //Will have to manually calculate :( $count = 0; @@ -65,7 +65,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return integer */ - function num_fields() + public function num_fields() { return @ibase_num_fields($this->result_id); } @@ -80,7 +80,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -102,7 +102,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); @@ -130,7 +130,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { @ibase_free_result($this->result_id); } @@ -147,7 +147,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access private * @return array */ - function _data_seek($n = 0) + public function _data_seek($n = 0) { //Interbase driver doesn't implement a sutable function return array(); @@ -163,7 +163,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access private * @return array */ - function _fetch_assoc() + public function _fetch_assoc() { return @ibase_fetch_assoc($this->result_id); } @@ -178,7 +178,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access private * @return object */ - function _fetch_object() + public function _fetch_object() { return @ibase_fetch_object($this->result_id); } diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index 533a269b2..d90ecae71 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -47,7 +47,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @access private * @return bool */ - function _list_databases() + public function _list_databases() { if ($this->db_debug) { @@ -67,7 +67,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @param string the table name * @return object */ - function _optimize_table($table) + public function _optimize_table($table) { return FALSE; } @@ -83,7 +83,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @param string the table name * @return object */ - function _repair_table($table) + public function _repair_table($table) { return FALSE; } @@ -97,7 +97,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 2d6ae793daf6eafe72c33f2bc39e18a22f699264 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 15:00:52 -0500 Subject: Various fixes --- .../drivers/interbase/interbase_driver.php | 226 +++++++++++---------- 1 file changed, 115 insertions(+), 111 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 671b128ea..ff9f2d5bf 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -14,15 +14,15 @@ * 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. + * licensingellislab.com so we can send you a copy immediately. * - * @package CodeIgniter - * @author EllisLab Dev Team - * @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 3.0 - * @filesource + * package CodeIgniter + * author EllisLab Dev Team + * 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 3.0 + * filesource */ // ------------------------------------------------------------------------ @@ -36,11 +36,11 @@ * creates dynamically based on whether the active record * class is being used or not. * - * @package CodeIgniter - * @subpackage Drivers - * @category Database - * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/database/ + * package CodeIgniter + * subpackage Drivers + * category Database + * author EllisLab Dev Team + * link http://codeigniter.com/user_guide/database/ */ class CI_DB_interbase_driver extends CI_DB { @@ -67,12 +67,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class - * @return resource + * access private called by the base class + * return resource */ public function db_connect() { - if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->charset)) + if ( ! $conn_id = ibase_connect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -92,12 +92,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class - * @return resource + * access private called by the base class + * return resource */ public function db_pconnect() { - if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->charset)) + if ( ! $conn_id = ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -120,8 +120,8 @@ class CI_DB_interbase_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public - * @return void + * access public + * return void */ public function reconnect() { @@ -133,8 +133,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * @access private called by the base class - * @return resource + * access private called by the base class + * return resource */ public function db_select() { @@ -147,14 +147,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Set client character set * - * @access public - * @param string - * @param string - * @return resource + * access public + * param string + * param string + * return resource */ public function db_set_charset($charset, $collation) { - // @todo - add support if needed + // todo - add support if needed return TRUE; } @@ -163,12 +163,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Version number query string * - * @access public - * @return string + * access public + * return string */ public function _version() { - //@todo - add support if needed + //todo - add support if needed return TRUE; } @@ -177,14 +177,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class - * @param string an SQL query - * @return resource + * access private called by the base class + * param string an SQL query + * return resource */ public function _execute($sql) { $sql = $this->_prep_query($sql); - return @ibase_query($this->conn_id, $sql); + return ibase_query($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -194,9 +194,9 @@ class CI_DB_interbase_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() - * @param string an SQL query - * @return string + * access private called by execute() + * param string an SQL query + * return string */ public function _prep_query($sql) { @@ -208,8 +208,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Begin Transaction * - * @access public - * @return bool + * access public + * return bool */ public function trans_begin($test_mode = FALSE) { @@ -229,7 +229,7 @@ class CI_DB_interbase_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; - $this->trans = @ibase_trans($this->conn_id); + $this->trans = ibase_trans($this->conn_id); return TRUE; } @@ -239,8 +239,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Commit Transaction * - * @access public - * @return bool + * access public + * return bool */ public function trans_commit() { @@ -255,7 +255,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_commit($this->trans); + ibase_commit($this->trans); return TRUE; } @@ -265,8 +265,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Rollback Transaction * - * @access public - * @return bool + * access public + * return bool */ public function trans_rollback() { @@ -281,7 +281,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_rollback($this->trans); + ibase_rollback($this->trans); return TRUE; } @@ -291,10 +291,10 @@ class CI_DB_interbase_driver extends CI_DB { /** * Escape String * - * @access public - * @param string - * @param bool whether or not the string will be used in a LIKE condition - * @return string + * access public + * param string + * param bool whether or not the string will be used in a LIKE condition + * return string */ public function escape_str($str, $like = FALSE) { @@ -324,12 +324,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * access public + * return integer */ public function affected_rows() { - return @ibase_affected_rows($this->conn_id); + return ibase_affected_rows($this->conn_id); } // -------------------------------------------------------------------- @@ -337,12 +337,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * access public + * return integer */ public function insert_id() { - //@todo Implement manually + //todo Implement manually return 0; } @@ -354,9 +354,9 @@ class CI_DB_interbase_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public - * @param string - * @return string + * access public + * param string + * return string */ public function count_all($table = '') { @@ -384,9 +384,9 @@ class CI_DB_interbase_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean - * @return string + * access private + * param boolean + * return string */ public function _list_tables($prefix_limit = FALSE) { @@ -410,9 +410,9 @@ SQL; * * Generates a platform-specific query string so that the column names can be fetched * - * @access public - * @param string the table name - * @return string + * access public + * param string the table name + * return string */ public function _list_columns($table = '') { @@ -427,9 +427,9 @@ SQL; * * Generates a platform-specific query so that the column data can be retrieved * - * @access public - * @param string the table name - * @return object + * access public + * param string the table name + * return object */ public function _field_data($table) { @@ -441,8 +441,8 @@ SQL; /** * The error message string * - * @access private - * @return string + * access private + * return string */ public function _error_message() { @@ -454,8 +454,8 @@ SQL; /** * The error message number * - * @access private - * @return integer + * access private + * return integer */ public function _error_number() { @@ -469,9 +469,9 @@ SQL; * * This public function escapes column and table names * - * @access private - * @param string - * @return string + * access private + * param string + * return string */ public function _escape_identifiers($item) { @@ -496,7 +496,7 @@ SQL; } // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + return strtoupper(preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str)); } // -------------------------------------------------------------------- @@ -507,9 +507,9 @@ SQL; * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * access public + * param type + * return type */ public function _from_tables($tables) { @@ -518,7 +518,7 @@ SQL; $tables = array($tables); } - return '('.implode(', ', $tables).')'; + return strtolower(implode(', ', $tables)); } // -------------------------------------------------------------------- @@ -528,15 +528,15 @@ SQL; * * Generates a platform-specific insert string from the supplied data * - * @access public - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * access public + * param string the table name + * param array the insert keys + * param array the insert values + * return string */ public function _insert($table, $keys, $values) { - return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return "INSERT INTO ".strtolower($table)." (".strtoupper(implode(', ', $keys)).") VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -546,16 +546,18 @@ SQL; * * Generates a platform-specific update string from the supplied data * - * @access public - * @param string the table name - * @param array the update data - * @param array the where clause - * @param array the orderby clause - * @param array the limit clause - * @return string + * access public + * param string the table name + * param array the update data + * param array the where clause + * param array the orderby clause + * param array the limit clause + * return string */ public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { + $table = strtolower($table); + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; @@ -584,9 +586,9 @@ SQL; * If the database does not support the truncate() command * This public function maps to "DELETE FROM table" * - * @access public - * @param string the table name - * @return string + * access public + * param string the table name + * return string */ public function _truncate($table) { @@ -600,14 +602,16 @@ SQL; * * Generates a platform-specific delete string from the supplied data * - * @access public - * @param string the table name - * @param array the where clause - * @param string the limit clause - * @return string + * access public + * param string the table name + * param array the where clause + * param string the limit clause + * return string */ public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { + $table = strtolower($table); + $conditions = ''; if (count($where) > 0 OR count($like) > 0) @@ -634,11 +638,11 @@ SQL; * * Generates a platform-specific LIMIT clause * - * @access public - * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value - * @return string + * access public + * param string the sql query string + * param integer the number of rows to limit the query to + * param integer the offset value + * return string */ public function _limit($sql, $limit, $offset) { @@ -659,13 +663,13 @@ SQL; /** * Close DB Connection * - * @access public - * @param resource - * @return void + * access public + * param resource + * return void */ public function _close($conn_id) { - @ibase_close($conn_id); + ibase_close($conn_id); } -- cgit v1.2.3-24-g4f1b From 7221f9455b3ffe89474d1728583b656c176b5ba4 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 15:02:33 -0500 Subject: Restored '@' characters --- .../drivers/interbase/interbase_driver.php | 218 ++++++++++----------- 1 file changed, 108 insertions(+), 110 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index ff9f2d5bf..525294db4 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -14,15 +14,15 @@ * 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 - * licensingellislab.com so we can send you a copy immediately. + * licensing@ellislab.com so we can send you a copy immediately. * - * package CodeIgniter - * author EllisLab Dev Team - * 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 3.0 - * filesource + * @package CodeIgniter + * @author EllisLab Dev Team + * @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 3.0 + * @filesource */ // ------------------------------------------------------------------------ @@ -36,11 +36,11 @@ * creates dynamically based on whether the active record * class is being used or not. * - * package CodeIgniter - * subpackage Drivers - * category Database - * author EllisLab Dev Team - * link http://codeigniter.com/user_guide/database/ + * @package CodeIgniter + * @subpackage Drivers + * @category Database + * @author EllisLab Dev Team + * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_interbase_driver extends CI_DB { @@ -67,12 +67,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Non-persistent database connection * - * access private called by the base class - * return resource + * @access private called by the base class + * @return resource */ public function db_connect() { - if ( ! $conn_id = ibase_connect($this->database, $this->username, $this->password, $this->char_set)) + if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -92,12 +92,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Persistent database connection * - * access private called by the base class - * return resource + * @access private called by the base class + * @return resource */ public function db_pconnect() { - if ( ! $conn_id = ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) + if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -120,8 +120,8 @@ class CI_DB_interbase_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * access public - * return void + * @access public + * @return void */ public function reconnect() { @@ -133,8 +133,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * access private called by the base class - * return resource + * @access private called by the base class + * @return resource */ public function db_select() { @@ -147,14 +147,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Set client character set * - * access public - * param string - * param string - * return resource + * @access public + * @param string + * @param string + * @return resource */ public function db_set_charset($charset, $collation) { - // todo - add support if needed + // @todo - add support if needed return TRUE; } @@ -163,12 +163,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Version number query string * - * access public - * return string + * @access public + * @return string */ public function _version() { - //todo - add support if needed + //@todo - add support if needed return TRUE; } @@ -177,14 +177,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Execute the query * - * access private called by the base class - * param string an SQL query - * return resource + * @access private called by the base class + * @param string an SQL query + * @return resource */ public function _execute($sql) { $sql = $this->_prep_query($sql); - return ibase_query($this->conn_id, $sql); + return @ibase_query($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -194,9 +194,9 @@ class CI_DB_interbase_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * access private called by execute() - * param string an SQL query - * return string + * @access private called by execute() + * @param string an SQL query + * @return string */ public function _prep_query($sql) { @@ -208,8 +208,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Begin Transaction * - * access public - * return bool + * @access public + * @return bool */ public function trans_begin($test_mode = FALSE) { @@ -229,7 +229,7 @@ class CI_DB_interbase_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; - $this->trans = ibase_trans($this->conn_id); + $this->trans = @ibase_trans($this->conn_id); return TRUE; } @@ -239,8 +239,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Commit Transaction * - * access public - * return bool + * @access public + * @return bool */ public function trans_commit() { @@ -255,7 +255,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - ibase_commit($this->trans); + @ibase_commit($this->trans); return TRUE; } @@ -265,8 +265,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Rollback Transaction * - * access public - * return bool + * @access public + * @return bool */ public function trans_rollback() { @@ -281,7 +281,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - ibase_rollback($this->trans); + @ibase_rollback($this->trans); return TRUE; } @@ -291,10 +291,10 @@ class CI_DB_interbase_driver extends CI_DB { /** * Escape String * - * access public - * param string - * param bool whether or not the string will be used in a LIKE condition - * return string + * @access public + * @param string + * @param bool whether or not the string will be used in a LIKE condition + * @return string */ public function escape_str($str, $like = FALSE) { @@ -324,12 +324,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Affected Rows * - * access public - * return integer + * @access public + * @return integer */ public function affected_rows() { - return ibase_affected_rows($this->conn_id); + return @ibase_affected_rows($this->conn_id); } // -------------------------------------------------------------------- @@ -337,12 +337,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * access public - * return integer + * @access public + * @return integer */ public function insert_id() { - //todo Implement manually + //@todo Implement manually return 0; } @@ -354,9 +354,9 @@ class CI_DB_interbase_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * access public - * param string - * return string + * @access public + * @param string + * @return string */ public function count_all($table = '') { @@ -384,9 +384,9 @@ class CI_DB_interbase_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * access private - * param boolean - * return string + * @access private + * @param boolean + * @return string */ public function _list_tables($prefix_limit = FALSE) { @@ -410,9 +410,9 @@ SQL; * * Generates a platform-specific query string so that the column names can be fetched * - * access public - * param string the table name - * return string + * @access public + * @param string the table name + * @return string */ public function _list_columns($table = '') { @@ -427,9 +427,9 @@ SQL; * * Generates a platform-specific query so that the column data can be retrieved * - * access public - * param string the table name - * return object + * @access public + * @param string the table name + * @return object */ public function _field_data($table) { @@ -441,8 +441,8 @@ SQL; /** * The error message string * - * access private - * return string + * @access private + * @return string */ public function _error_message() { @@ -454,8 +454,8 @@ SQL; /** * The error message number * - * access private - * return integer + * @access private + * @return integer */ public function _error_number() { @@ -469,9 +469,9 @@ SQL; * * This public function escapes column and table names * - * access private - * param string - * return string + * @access private + * @param string + * @return string */ public function _escape_identifiers($item) { @@ -507,9 +507,9 @@ SQL; * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * access public - * param type - * return type + * @access public + * @param type + * @return type */ public function _from_tables($tables) { @@ -528,11 +528,11 @@ SQL; * * Generates a platform-specific insert string from the supplied data * - * access public - * param string the table name - * param array the insert keys - * param array the insert values - * return string + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ public function _insert($table, $keys, $values) { @@ -546,13 +546,13 @@ SQL; * * Generates a platform-specific update string from the supplied data * - * access public - * param string the table name - * param array the update data - * param array the where clause - * param array the orderby clause - * param array the limit clause - * return string + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @param array the orderby clause + * @param array the limit clause + * @return string */ public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { @@ -586,9 +586,9 @@ SQL; * If the database does not support the truncate() command * This public function maps to "DELETE FROM table" * - * access public - * param string the table name - * return string + * @access public + * @param string the table name + * @return string */ public function _truncate($table) { @@ -602,11 +602,11 @@ SQL; * * Generates a platform-specific delete string from the supplied data * - * access public - * param string the table name - * param array the where clause - * param string the limit clause - * return string + * @access public + * @param string the table name + * @param array the where clause + * @param string the limit clause + * @return string */ public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { @@ -638,11 +638,11 @@ SQL; * * Generates a platform-specific LIMIT clause * - * access public - * param string the sql query string - * param integer the number of rows to limit the query to - * param integer the offset value - * return string + * @access public + * @param string the sql query string + * @param integer the number of rows to limit the query to + * @param integer the offset value + * @return string */ public function _limit($sql, $limit, $offset) { @@ -663,16 +663,14 @@ SQL; /** * Close DB Connection * - * access public - * param resource - * return void + * @access public + * @param resource + * @return void */ public function _close($conn_id) { - ibase_close($conn_id); + @ibase_close($conn_id); } - - } -- cgit v1.2.3-24-g4f1b From d19e47a3152c0a3e6a9aa13261b4c843c946523b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 23:40:40 -0500 Subject: Removed string case manipulation functions --- system/database/drivers/interbase/interbase_driver.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 525294db4..6f889d91e 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -74,11 +74,11 @@ class CI_DB_interbase_driver extends CI_DB { { if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->char_set)) { - log_message('error', $error); + log_message('error', $this->_error_message()); if ($this->db_debug) { - $this->display_error($error, '', TRUE); + $this->display_error($this->_error_message(), '', TRUE); } return FALSE; @@ -99,11 +99,11 @@ class CI_DB_interbase_driver extends CI_DB { { if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) { - log_message('error', $error); + log_message('error', $this->_error_message()); if ($this->db_debug) { - $this->display_error($error, '', TRUE); + $this->display_error($this->_error_message(), '', TRUE); } return FALSE; @@ -496,7 +496,7 @@ SQL; } // remove duplicates if the user already included the escape - return strtoupper(preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str)); + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } // -------------------------------------------------------------------- @@ -518,7 +518,7 @@ SQL; $tables = array($tables); } - return strtolower(implode(', ', $tables)); + return implode(', ', $tables); } // -------------------------------------------------------------------- @@ -536,7 +536,7 @@ SQL; */ public function _insert($table, $keys, $values) { - return "INSERT INTO ".strtolower($table)." (".strtoupper(implode(', ', $keys)).") VALUES (".implode(', ', $values).")"; + return "INSERT INTO {$table} (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -556,8 +556,6 @@ SQL; */ public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - $table = strtolower($table); - foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; @@ -610,8 +608,6 @@ SQL; */ public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { - $table = strtolower($table); - $conditions = ''; if (count($where) > 0 OR count($like) > 0) -- cgit v1.2.3-24-g4f1b From 498fa354888c1fc4083d1e464b651498d9338b64 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 15 Feb 2012 10:05:49 -0500 Subject: Minor codestyle fix --- system/database/drivers/interbase/interbase_driver.php | 2 -- system/database/drivers/interbase/interbase_utility.php | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 6f889d91e..a011f103d 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -27,8 +27,6 @@ // ------------------------------------------------------------------------ - - /** * Firebird/Interbase Database Adapter Class * diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index d90ecae71..764275567 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -100,6 +100,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { public function _backup($params = array()) { // Currently unsupported + // @todo See if can be implemented return $this->db->display_error('db_unsuported_feature'); } } -- cgit v1.2.3-24-g4f1b From 3d985a19ac05a8f5141b51fed9b1b37946733792 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 15 Feb 2012 11:38:00 -0500 Subject: Syntax fixes --- .../drivers/interbase/interbase_driver.php | 27 ++++++++++------------ .../database/drivers/interbase/interbase_forge.php | 13 ++--------- 2 files changed, 14 insertions(+), 26 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index a011f103d..36ef42ef3 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -152,7 +152,7 @@ class CI_DB_interbase_driver extends CI_DB { */ public function db_set_charset($charset, $collation) { - // @todo - add support if needed + // Must be determined at connection return TRUE; } @@ -166,8 +166,13 @@ class CI_DB_interbase_driver extends CI_DB { */ public function _version() { - //@todo - add support if needed - return TRUE; + if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) + { + $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); + return $version; + } + + return FALSE; } // -------------------------------------------------------------------- @@ -396,7 +401,7 @@ SQL; if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); + $sql .= ' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } return $sql; } @@ -620,7 +625,7 @@ SQL; $conditions .= implode("\n", $like); } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit; return "DELETE FROM ".$table.$conditions.$limit; } @@ -640,16 +645,8 @@ SQL; */ public function _limit($sql, $limit, $offset) { - if ($offset == 0) - { - $offset = ''; - } - else - { - $offset .= ", "; - } - - return $sql."LIMIT ".$offset.$limit; + //There doesn't seem to be a limit clause? + return $sql; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 815107d85..177433fc4 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -205,20 +205,11 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); - // DROP has everything it needs now. - /*if ($alter_type == 'DROP') - { - // SQLite does not support dropping columns - // http://www.sqlite.org/omitted.html - // http://www.sqlite.org/faq.html#q11 - return FALSE; - }*/ - - $sql .= " $column_definition"; + $sql .= " {$column_definition}"; if ($default_value != '') { - $sql .= " DEFAULT \"$default_value\""; + $sql .= " DEFAULT \"{$default_value}\""; } if ($null === NULL) -- cgit v1.2.3-24-g4f1b From 8be31a92758959d7fd7b035e36b9799da13426ae Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 15 Feb 2012 11:48:57 -0500 Subject: Limit clause fixes --- system/database/drivers/interbase/interbase_driver.php | 12 +++++++----- system/database/drivers/interbase/interbase_result.php | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 36ef42ef3..197c01401 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -436,7 +436,10 @@ SQL; */ public function _field_data($table) { - return "SELECT * FROM ".$table." LIMIT 1"; + // Need to find a more efficient way to do this + // but Interbase/Firebird seems to lack the + // limit clause + return "SELECT * FROM {$table}"; } // -------------------------------------------------------------------- @@ -564,7 +567,7 @@ SQL; $valstr[] = $key." = ".$val; } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit; $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; @@ -572,7 +575,7 @@ SQL; $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; - $sql .= $orderby.$limit; + $sql .= $orderby; return $sql; } @@ -627,7 +630,7 @@ SQL; //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - return "DELETE FROM ".$table.$conditions.$limit; + return "DELETE FROM {$table}{$conditions}"; } // -------------------------------------------------------------------- @@ -664,6 +667,5 @@ SQL; } } - /* End of file interbase_driver.php */ /* Location: ./system/database/drivers/interbase/interbase_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 9d827895d..f2465ab5d 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -149,7 +149,7 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function _data_seek($n = 0) { - //Interbase driver doesn't implement a sutable function + //Interbase driver doesn't implement a suitable function return array(); } @@ -185,6 +185,5 @@ class CI_DB_interbase_result extends CI_DB_result { } - /* End of file interbase_result.php */ /* Location: ./system/database/drivers/interbase/interbase_result.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6e09f238acfa8f3d1180ff3f640c65aeffbc4379 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 15 Feb 2012 18:23:08 +0100 Subject: Lowered the file permissions for file caches. See #1045 for more information. Signed-off-by: Yorick Peterse --- system/libraries/Cache/drivers/Cache_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 4a81b0422..a960730d7 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -99,7 +99,7 @@ class CI_Cache_file extends CI_Driver { if (write_file($this->_cache_path.$id, serialize($contents))) { - @chmod($this->_cache_path.$id, 0777); + @chmod($this->_cache_path.$id, 0660); return TRUE; } -- cgit v1.2.3-24-g4f1b From eb6dcf058bd0cc6e5f3b6a793491d4a1c144155b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 15 Feb 2012 16:48:51 -0500 Subject: Implemented _list_columns() method --- system/database/drivers/interbase/interbase_driver.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 197c01401..8a156af53 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -419,8 +419,17 @@ SQL; */ public function _list_columns($table = '') { - // Not supported - return FALSE; + $sql = << Date: Wed, 15 Feb 2012 18:40:39 -0500 Subject: Implemented insert_id() method --- system/database/drivers/interbase/interbase_driver.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 8a156af53..97bf722db 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -341,12 +341,13 @@ class CI_DB_interbase_driver extends CI_DB { * Insert ID * * @access public + * @param string $generator_name + * @param integer $inc_by * @return integer */ - public function insert_id() + public function insert_id($generator_name, $inc_by=1) { - //@todo Implement manually - return 0; + return ibase_gen_id($generator_name, $inc_by); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 817af19bb12b88bae361034e00ce3a02da595f94 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 16 Feb 2012 08:28:00 -0500 Subject: narfbg suggested fixes --- system/database/DB_driver.php | 2 +- .../drivers/interbase/interbase_driver.php | 86 ++++++---------------- .../database/drivers/interbase/interbase_forge.php | 20 ++--- .../drivers/interbase/interbase_result.php | 30 +++----- .../drivers/interbase/interbase_utility.php | 12 +-- 5 files changed, 44 insertions(+), 106 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index b829bbe46..7c73fc257 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -256,7 +256,7 @@ class CI_DB_driver { // Some DBs have functions that return the version, and don't run special // SQL queries per se. In these instances, just return the result. - $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli'); + $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli', 'interbase'); if (in_array($this->dbdriver, $driver_version_exceptions)) { diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 97bf722db..a6f192ad1 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -1,13 +1,13 @@ -hostname) && $this->hostname !== "localhost") + { + $this->database = $this->hostname.':'.$this->database; + } + } /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ public function db_connect() { - if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->char_set)) - { - log_message('error', $this->_error_message()); - - if ($this->db_debug) - { - $this->display_error($this->_error_message(), '', TRUE); - } - - return FALSE; - } - - return $conn_id; + return @ibase_connect($this->database, $this->username, $this->password, $this->char_set); } // -------------------------------------------------------------------- @@ -90,24 +88,11 @@ class CI_DB_interbase_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ public function db_pconnect() { - if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) - { - log_message('error', $this->_error_message()); - - if ($this->db_debug) - { - $this->display_error($this->_error_message(), '', TRUE); - } - - return FALSE; - } - - return $conn_id; + return @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set); } // -------------------------------------------------------------------- @@ -118,7 +103,6 @@ class CI_DB_interbase_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ public function reconnect() @@ -131,7 +115,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ public function db_select() @@ -145,7 +128,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Set client character set * - * @access public * @param string * @param string * @return resource @@ -161,7 +143,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Version number query string * - * @access public * @return string */ public function _version() @@ -180,7 +161,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ @@ -197,7 +177,6 @@ class CI_DB_interbase_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ @@ -211,7 +190,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ public function trans_begin($test_mode = FALSE) @@ -242,7 +220,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ public function trans_commit() @@ -268,7 +245,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ public function trans_rollback() @@ -294,7 +270,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string @@ -327,7 +302,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ public function affected_rows() @@ -340,12 +314,11 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * @access public * @param string $generator_name * @param integer $inc_by * @return integer */ - public function insert_id($generator_name, $inc_by=1) + public function insert_id($generator_name, $inc_by=0) { return ibase_gen_id($generator_name, $inc_by); } @@ -358,7 +331,6 @@ class CI_DB_interbase_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ @@ -369,7 +341,7 @@ class CI_DB_interbase_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { @@ -388,7 +360,6 @@ class CI_DB_interbase_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ @@ -414,7 +385,6 @@ SQL; * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ @@ -440,7 +410,6 @@ SQL; * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ @@ -457,7 +426,6 @@ SQL; /** * The error message string * - * @access private * @return string */ public function _error_message() @@ -470,7 +438,6 @@ SQL; /** * The error message number * - * @access private * @return integer */ public function _error_number() @@ -485,7 +452,6 @@ SQL; * * This public function escapes column and table names * - * @access private * @param string * @return string */ @@ -523,7 +489,6 @@ SQL; * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ @@ -534,6 +499,7 @@ SQL; $tables = array($tables); } + //Interbase/Firebird doesn't like grouped tables return implode(', ', $tables); } @@ -544,7 +510,6 @@ SQL; * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values @@ -552,7 +517,7 @@ SQL; */ public function _insert($table, $keys, $values) { - return "INSERT INTO {$table} (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } // -------------------------------------------------------------------- @@ -562,7 +527,6 @@ SQL; * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -581,9 +545,9 @@ SQL; $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); + $sql = "UPDATE {$table} SET ".implode(', ', $valstr); - $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + $sql .= ($where != '' AND count($where) >=1) ? ' WHERE '.implode(' ', $where) : ''; $sql .= $orderby; @@ -600,7 +564,6 @@ SQL; * If the database does not support the truncate() command * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ @@ -616,7 +579,6 @@ SQL; * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause @@ -633,7 +595,7 @@ SQL; if (count($where) > 0 && count($like) > 0) { - $conditions .= " AND "; + $conditions .= ' AND '; } $conditions .= implode("\n", $like); } @@ -650,7 +612,6 @@ SQL; * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value @@ -667,7 +628,6 @@ SQL; /** * Close DB Connection * - * @access public * @param resource * @return void */ diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 177433fc4..6301481c5 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -1,13 +1,13 @@ -db->db_debug) - { - return $this->db->display_error('db_unsuported_feature'); - } - return array(); + return 'DROP TABLE '.$name; } // -------------------------------------------------------------------- @@ -191,7 +183,6 @@ class CI_DB_interbase_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -237,14 +228,13 @@ class CI_DB_interbase_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ public function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); return $sql; } } diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index f2465ab5d..7d56c56c6 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -1,13 +1,13 @@ -result_id)) + if( ! is_null($this->num_rows)) { - $count++; + return $this->num_rows; } - return $count; + return $this->num_rows = (isset($this->result_array()) ? count($this->result_array()) : 0; } // -------------------------------------------------------------------- @@ -62,7 +60,6 @@ class CI_DB_interbase_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ public function num_fields() @@ -77,13 +74,12 @@ class CI_DB_interbase_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ public function list_fields() { $field_names = array(); - for ($i = 0; $i < $this->num_fields(); $i++) + for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); $field_names[] = $info['name']; @@ -99,14 +95,13 @@ class CI_DB_interbase_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ public function field_data() { $retval = array(); - for ($i = 0; $i < $this->num_fields(); $i++) + for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); @@ -144,13 +139,12 @@ class CI_DB_interbase_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ public function _data_seek($n = 0) { //Interbase driver doesn't implement a suitable function - return array(); + return FALSE; } // -------------------------------------------------------------------- @@ -160,7 +154,6 @@ class CI_DB_interbase_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ public function _fetch_assoc() @@ -175,7 +168,6 @@ class CI_DB_interbase_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ public function _fetch_object() diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index 764275567..e31021acb 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -1,13 +1,13 @@ -db->display_error('db_unsuported_feature'); } - return array(); + return FALSE; } // -------------------------------------------------------------------- @@ -63,7 +62,6 @@ class CI_DB_interbase_utility extends CI_DB_utility { * * Is optimization even supported in Interbase/Firebird? * - * @access private * @param string the table name * @return object */ @@ -79,7 +77,6 @@ class CI_DB_interbase_utility extends CI_DB_utility { * * Table repairs are not supported in Interbase/Firebird * - * @access private * @param string the table name * @return object */ @@ -93,7 +90,6 @@ class CI_DB_interbase_utility extends CI_DB_utility { /** * Interbase/Firebird Export * - * @access private * @param array Preferences * @return mixed */ -- cgit v1.2.3-24-g4f1b From e27216f88443775534e185e192996353d4958387 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 16 Feb 2012 12:15:45 -0500 Subject: Num rows fix --- system/database/drivers/interbase/interbase_result.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 7d56c56c6..3d5721138 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -52,7 +52,7 @@ class CI_DB_interbase_result extends CI_DB_result { return $this->num_rows; } - return $this->num_rows = (isset($this->result_array()) ? count($this->result_array()) : 0; + return 0; } // -------------------------------------------------------------------- @@ -143,6 +143,9 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function _data_seek($n = 0) { + //Set the row count to 0 + $this->num_rows = 0; + //Interbase driver doesn't implement a suitable function return FALSE; } @@ -158,6 +161,9 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function _fetch_assoc() { + //Increment row count + $this->num_rows++; + return @ibase_fetch_assoc($this->result_id); } @@ -172,6 +178,9 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function _fetch_object() { + //Increment row count + $this->num_rows++; + return @ibase_fetch_object($this->result_id); } -- cgit v1.2.3-24-g4f1b From 3c4281f09dce0a97ab700d79e26308fdab350b73 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 16 Feb 2012 19:00:10 -0500 Subject: Simplified hostname connection logic --- system/database/drivers/interbase/interbase_driver.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index a6f192ad1..20663d8bb 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -61,17 +61,6 @@ class CI_DB_interbase_driver extends CI_DB { // Keeps track of the resource for the current transaction protected $trans; - - /** - * Constructor for some overall setup - */ - public function __construct() - { - if( ! empty($this->hostname) && $this->hostname !== "localhost") - { - $this->database = $this->hostname.':'.$this->database; - } - } /** * Non-persistent database connection @@ -80,7 +69,7 @@ class CI_DB_interbase_driver extends CI_DB { */ public function db_connect() { - return @ibase_connect($this->database, $this->username, $this->password, $this->char_set); + return @ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set); } // -------------------------------------------------------------------- @@ -92,7 +81,7 @@ class CI_DB_interbase_driver extends CI_DB { */ public function db_pconnect() { - return @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set); + return @ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 287dd450911251c3dc4d744c2e03fcd5d8a5b173 Mon Sep 17 00:00:00 2001 From: Marcos Garcia Date: Fri, 17 Feb 2012 02:26:22 +0100 Subject: Fixed issue #960 --- system/libraries/Cart.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index ba8d69be2..10b5362a5 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -329,13 +329,6 @@ class CI_Cart { return FALSE; } - // Is the new quantity different than what is already saved in the cart? - // If it's the same there's nothing to do - if ($this->_cart_contents[$items['rowid']]['qty'] == $items['qty']) - { - return FALSE; - } - // Is the quantity zero? If so we will remove the item from the cart. // If the quantity is greater than zero we are updating if ($items['qty'] == 0) -- cgit v1.2.3-24-g4f1b From 24dd2f9c5cc4476f19c67fe8df6b3ae9cc8a4bb3 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 17 Feb 2012 17:08:31 +0700 Subject: Syntax error, causing MySQL utility could not used --- system/database/drivers/mysql/mysql_utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 9d7cb679c..952f887fe 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -115,7 +115,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { if ($add_drop == TRUE) { - $output .= 'DROP TABLE IF EXISTS '.($this->db->protect_identifiers($table).';'.$newline.$newline; + $output .= 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table).';'.$newline.$newline; } $i = 0; -- cgit v1.2.3-24-g4f1b From 3a4cdc62042c56da9527e6d1d4c1ab5417839e1c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 13:59:44 -0500 Subject: Workaround to fix method --- .../drivers/interbase/interbase_driver.php | 53 ++++++++++++++++++ .../drivers/interbase/interbase_result.php | 62 ++++++++++++++++++++++ 2 files changed, 115 insertions(+) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 20663d8bb..7bd4f6f4b 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -624,6 +624,59 @@ SQL; { @ibase_close($conn_id); } + + // -------------------------------------------------------------------------- + + /** + * Returns an array of table names + * + * @access public + * @return array + */ + function list_tables($constrain_by_prefix = FALSE) + { + // Is there a cached result? + if (isset($this->data_cache['table_names'])) + { + return $this->data_cache['table_names']; + } + + if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) + { + if ($this->db_debug) + { + return $this->display_error('db_unsupported_function'); + } + return FALSE; + } + + $retval = array(); + $query = $this->query($sql); + + $table = FALSE; + $rows = $query->result_array(); + + // This has to be called after getting the result due to the + // limitations of the database driver + if ($query->num_rows() > 0) + { + $key = (($row = current($rows)) && in_array('table_name', array_map('strtolower', array_keys($row)))); + + if ($key) + { + $table = array_key_exists('TABLE_NAME', $row) ? 'TABLE_NAME' : 'table_name'; + } + + foreach ($rows as $row) + { + $retval[] = ( ! $table) ? current($row) : $row[$table]; + } + } + + $this->data_cache['table_names'] = $retval; + + return $this->data_cache['table_names']; + } } /* End of file interbase_driver.php */ diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 3d5721138..37f0a108c 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -183,6 +183,68 @@ class CI_DB_interbase_result extends CI_DB_result { return @ibase_fetch_object($this->result_id); } + + // -------------------------------------------------------------------- + + /** + * Query result. "object" version. + * + * @return object + */ + public function result_object() + { + if (count($this->result_object) > 0) + { + return $this->result_object; + } + + // In the event that query caching is on the result_id variable + // will return FALSE since there isn't a valid SQL resource so + // we'll simply return an empty array. + if ($this->result_id === FALSE) + { + return array(); + } + + $this->num_rows = 0; + while ($row = $this->_fetch_object()) + { + $this->result_object[] = $row; + } + + return $this->result_object; + } + + // -------------------------------------------------------------------- + + /** + * Query result. "array" version. + * + * @return array + */ + public function result_array() + { + if (count($this->result_array) > 0) + { + return $this->result_array; + } + + // In the event that query caching is on the result_id variable + // will return FALSE since there isn't a valid SQL resource so + // we'll simply return an empty array. + if ($this->result_id === FALSE) + { + return array(); + } + + $this->num_rows = 0; + while ($row = $this->_fetch_assoc()) + { + $this->result_array[] = $row; + } + + return $this->result_array; + } } -- cgit v1.2.3-24-g4f1b From 7d42eb39484a784496868f4446a2d47b0c52410d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 14:21:18 -0500 Subject: More general fix for num_rows --- .../drivers/interbase/interbase_driver.php | 53 ---------------------- .../drivers/interbase/interbase_result.php | 5 +- 2 files changed, 4 insertions(+), 54 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 7bd4f6f4b..20663d8bb 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -624,59 +624,6 @@ SQL; { @ibase_close($conn_id); } - - // -------------------------------------------------------------------------- - - /** - * Returns an array of table names - * - * @access public - * @return array - */ - function list_tables($constrain_by_prefix = FALSE) - { - // Is there a cached result? - if (isset($this->data_cache['table_names'])) - { - return $this->data_cache['table_names']; - } - - if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) - { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; - } - - $retval = array(); - $query = $this->query($sql); - - $table = FALSE; - $rows = $query->result_array(); - - // This has to be called after getting the result due to the - // limitations of the database driver - if ($query->num_rows() > 0) - { - $key = (($row = current($rows)) && in_array('table_name', array_map('strtolower', array_keys($row)))); - - if ($key) - { - $table = array_key_exists('TABLE_NAME', $row) ? 'TABLE_NAME' : 'table_name'; - } - - foreach ($rows as $row) - { - $retval[] = ( ! $table) ? current($row) : $row[$table]; - } - } - - $this->data_cache['table_names'] = $retval; - - return $this->data_cache['table_names']; - } } /* End of file interbase_driver.php */ diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 37f0a108c..9093029dd 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -52,7 +52,10 @@ class CI_DB_interbase_result extends CI_DB_result { return $this->num_rows; } - return 0; + //Get the results so that you can get an accurate rowcount + $this->result_array(); + + return $this->num_rows; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From c2b712eb5230fc247ef81b4b88de789b9dd08cb4 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 15:58:08 -0500 Subject: implemented create_database, misc cleanup --- .../database/drivers/interbase/interbase_driver.php | 17 ++++++----------- .../database/drivers/interbase/interbase_forge.php | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 21 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 20663d8bb..bc7365e4d 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -104,7 +104,7 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * @return resource + * @return bool */ public function db_select() { @@ -119,7 +119,7 @@ class CI_DB_interbase_driver extends CI_DB { * * @param string * @param string - * @return resource + * @return bool */ public function db_set_charset($charset, $collation) { @@ -332,6 +332,8 @@ class CI_DB_interbase_driver extends CI_DB { $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query->result_array(); + if ($query->num_rows() == 0) { return 0; @@ -379,17 +381,10 @@ SQL; */ public function _list_columns($table = '') { - $sql = <<hostname.':'.$filename.'"'; + } // -------------------------------------------------------------------- @@ -72,7 +73,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param mixed primary key(s) * @param mixed key(s) * @param boolean should 'IF NOT EXISTS' be added to the SQL - * @return bool + * @return string */ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { @@ -168,7 +169,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { /** * Drop Table * - * @return bool + * @return string */ public function _drop_table($table) { @@ -190,7 +191,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the default value * @param boolean should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { @@ -234,8 +235,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { */ public function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); } } -- cgit v1.2.3-24-g4f1b From 0dcfd778350ce397b034f44e34397ea255b35809 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 17:42:34 -0500 Subject: Automatic retreival of blob fields --- system/database/drivers/interbase/interbase_result.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 9093029dd..c5608d977 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -167,7 +167,7 @@ class CI_DB_interbase_result extends CI_DB_result { //Increment row count $this->num_rows++; - return @ibase_fetch_assoc($this->result_id); + return @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS); } // -------------------------------------------------------------------- @@ -184,7 +184,7 @@ class CI_DB_interbase_result extends CI_DB_result { //Increment row count $this->num_rows++; - return @ibase_fetch_object($this->result_id); + return @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 4e44b344d79b52c7b79489b7e3d137d5ed66ab21 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sat, 18 Feb 2012 22:47:36 +0700 Subject: Fixed meta table method(s) for PDO --- system/database/drivers/pdo/pdo_driver.php | 21 +++++++++++++++ system/database/drivers/pdo/pdo_result.php | 43 ++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index de2b0abeb..9e8e1f66a 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -591,6 +591,11 @@ class CI_DB_pdo_driver extends CI_DB { // Analog function to show all tables in postgre $sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"; } + elseif ($this->pdodriver == 'sqlite') + { + // Analog function to show all tables in sqlite + $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"; + } else { $sql = "SHOW TABLES FROM `".$this->database."`"; @@ -633,6 +638,22 @@ class CI_DB_pdo_driver extends CI_DB { */ function _field_data($table) { + if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql') + { + // Analog function for mysql and postgre + return 'SELECT * FROM '.$this->_from_tables($table).' LIMIT 1'; + } + elseif ($this->pdodriver == 'oci') + { + // Analog function for oci + return 'SELECT * FROM '.$this->_from_tables($table).' WHERE ROWNUM <= 1'; + } + elseif ($this->pdodriver == 'sqlite') + { + // Analog function for sqlite + return 'PRAGMA table_info('.$this->_from_tables($table).')'; + } + return 'SELECT TOP 1 FROM '.$this->_from_tables($table); } diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index c333abc40..213b5d670 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -160,9 +160,48 @@ class CI_DB_pdo_result extends CI_DB_result { try { - for($i = 0; $i < $this->num_fields(); $i++) + if (strpos($this->result_id->queryString, 'PRAGMA') !== FALSE) { - $data[] = $this->result_id->getColumnMeta($i); + foreach($this->result_array() as $field) + { + preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field['type'], $matches); + + $F = new stdClass(); + $F->name = $field['name']; + $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL; + $F->default = NULL; + $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL; + $F->primary_key = (int) $field['pk']; + $F->pdo_type = NULL; + + $data[] = $F; + } + } + else + { + for($i = 0, $max = $this->num_fields(); $i < $max; $i++) + { + $field = $this->result_id->getColumnMeta($i); + + $F = new stdClass(); + $F->name = $field['name']; + $F->type = $field['native_type']; + $F->default = NULL; + $F->pdo_type = $field['pdo_type']; + + if ($field['precision'] < 0) + { + $F->max_length = NULL; + $F->primary_key = 0; + } + else + { + $F->max_length = ($field['len'] > 255) ? NULL : (string) $field['len']; + $F->primary_key = (int) (array_key_exists('flags', $field) && in_array('primary_key', $field['flags'])); + } + + $data[] = $F; + } } return $data; -- cgit v1.2.3-24-g4f1b From 53e24f08f930d53dc0e23d180e14d452f97addf9 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 11:55:31 -0500 Subject: Properly escape generator name --- system/database/drivers/interbase/interbase_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index bc7365e4d..fcefa6d97 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -309,7 +309,7 @@ class CI_DB_interbase_driver extends CI_DB { */ public function insert_id($generator_name, $inc_by=0) { - return ibase_gen_id($generator_name, $inc_by); + return ibase_gen_id('"'.$generator_name.'"', $inc_by); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fa84d6186b7f61353d04132871a5223f80fa12ee Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 12:51:45 -0500 Subject: Fixed result array fetching --- system/database/drivers/interbase/interbase_result.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index c5608d977..c7b40d2ea 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -53,7 +53,7 @@ class CI_DB_interbase_result extends CI_DB_result { } //Get the results so that you can get an accurate rowcount - $this->result_array(); + $this->result(); return $this->num_rows; } @@ -231,6 +231,14 @@ class CI_DB_interbase_result extends CI_DB_result { { return $this->result_array; } + + // Since the object and array are really similar, just case + // the result object to an array if need be + if(count($this->result_object) > 0) + { + $this->result_array = (array)$this->result_object; + return $this->result_array; + } // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so -- cgit v1.2.3-24-g4f1b From 53d109dbd831506c4b9ca77f10bc1b2dba9c28d5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 13:04:48 -0500 Subject: Fix previous commit --- system/database/drivers/interbase/interbase_result.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index c7b40d2ea..de4a10b62 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -236,7 +236,11 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if(count($this->result_object) > 0) { - $this->result_array = (array)$this->result_object; + foreach($this->result_object as $obj) + { + $this->result_array[] = (array)$obj; + } + return $this->result_array; } -- cgit v1.2.3-24-g4f1b From 07b660b56dcf608b64fc1811c602c4072c276e70 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 13:23:06 -0500 Subject: Fixed insert_id possibly returning 0 --- system/database/drivers/interbase/interbase_driver.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index fcefa6d97..4044c4529 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -309,7 +309,12 @@ class CI_DB_interbase_driver extends CI_DB { */ public function insert_id($generator_name, $inc_by=0) { - return ibase_gen_id('"'.$generator_name.'"', $inc_by); + //If a generator hasn't been used before it will return 0 + if($id = ibase_gen_id('"'.$generator_name.'"', $inc_by) !== 0) + { + return $id; + } + return ibase_gen_id('"'.$generator_name.'"', 1); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 934e853d9a3a491911b72f40cb371edfaddb9c94 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 15:42:14 -0500 Subject: Revert "Fix previous commit" This reverts commit 53d109dbd831506c4b9ca77f10bc1b2dba9c28d5. --- system/database/drivers/interbase/interbase_result.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index de4a10b62..c7b40d2ea 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -236,11 +236,7 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if(count($this->result_object) > 0) { - foreach($this->result_object as $obj) - { - $this->result_array[] = (array)$obj; - } - + $this->result_array = (array)$this->result_object; return $this->result_array; } -- cgit v1.2.3-24-g4f1b From fed2d1ddecae1886486915718cb9878b7d5aea45 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 15:42:45 -0500 Subject: Revert previous commit --- system/database/drivers/interbase/interbase_driver.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 4044c4529..aeea00d7f 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -310,11 +310,7 @@ class CI_DB_interbase_driver extends CI_DB { public function insert_id($generator_name, $inc_by=0) { //If a generator hasn't been used before it will return 0 - if($id = ibase_gen_id('"'.$generator_name.'"', $inc_by) !== 0) - { - return $id; - } - return ibase_gen_id('"'.$generator_name.'"', 1); + return ibase_gen_id('"'.$generator_name.'"', $inc_by); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 51ed4ed7f6097a34ce1db7b225272bfc1b0f0bcf Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 16:01:42 -0500 Subject: Convert result_array to result_object instead of re-fetching --- .../drivers/interbase/interbase_result.php | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index c7b40d2ea..e1332ba93 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -200,6 +200,27 @@ class CI_DB_interbase_result extends CI_DB_result { { return $this->result_object; } + + // Convert result array to object so that + // We don't have to get the result again + if(count($this->result_array) > 0) + { + $i = 0; + + foreach($this->result_array as $array) + { + $this->result_object[$i] = new StdClass(); + + foreach($array as $key => $val) + { + $this->result_object[$i]->{$key} = $val; + } + + ++$i; + } + + return $this->result_object; + } // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so @@ -236,7 +257,11 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if(count($this->result_object) > 0) { - $this->result_array = (array)$this->result_object; + foreach($this->result_object as $obj) + { + $this->result_array[] = (array)$obj; + } + return $this->result_array; } -- cgit v1.2.3-24-g4f1b From 95562144da88784588fb2477fa0070576bd386a0 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 17:37:21 -0500 Subject: Set protected visibility on applicable functions/properties --- .../drivers/interbase/interbase_driver.php | 44 +++++++++++----------- .../database/drivers/interbase/interbase_forge.php | 12 +++--- .../drivers/interbase/interbase_result.php | 6 +-- 3 files changed, 30 insertions(+), 32 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index aeea00d7f..ba4f9d8d9 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -45,19 +45,19 @@ class CI_DB_interbase_driver extends CI_DB { public $dbdriver = 'interbase'; // The character used to escape with - public $_escape_char = '"'; + protected $_escape_char = '"'; // clause and character used for LIKE escape sequences - public $_like_escape_str = " ESCAPE '%s' "; - public $_like_escape_chr = '!'; + protected $_like_escape_str = " ESCAPE '%s' "; + 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. */ - public $_count_string = "SELECT COUNT(*) AS "; - public $_random_keyword = ' Random()'; // database specific random keyword + protected $_count_string = "SELECT COUNT(*) AS "; + protected $_random_keyword = ' Random()'; // database specific random keyword // Keeps track of the resource for the current transaction protected $trans; @@ -134,7 +134,7 @@ class CI_DB_interbase_driver extends CI_DB { * * @return string */ - public function _version() + protected function _version() { if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) { @@ -153,7 +153,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return resource */ - public function _execute($sql) + protected function _execute($sql) { $sql = $this->_prep_query($sql); return @ibase_query($this->conn_id, $sql); @@ -169,7 +169,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return string */ - public function _prep_query($sql) + protected function _prep_query($sql) { return $sql; } @@ -333,8 +333,6 @@ class CI_DB_interbase_driver extends CI_DB { $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - $query->result_array(); - if ($query->num_rows() == 0) { return 0; @@ -355,7 +353,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param boolean * @return string */ - public function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = <<_reserved_identifiers as $id) { @@ -477,7 +475,7 @@ SQL; * @param type * @return type */ - public function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -500,7 +498,7 @@ SQL; * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } @@ -519,7 +517,7 @@ SQL; * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -552,7 +550,7 @@ SQL; * @param string the table name * @return string */ - public function _truncate($table) + protected function _truncate($table) { return $this->_delete($table); } @@ -569,7 +567,7 @@ SQL; * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -602,7 +600,7 @@ SQL; * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { //There doesn't seem to be a limit clause? return $sql; @@ -616,7 +614,7 @@ SQL; * @param resource * @return void */ - public function _close($conn_id) + protected function _close($conn_id) { @ibase_close($conn_id); } diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index d9b55a87f..c7372a0bf 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -42,7 +42,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the database name * @return string */ - public function _create_database($filename='') + protected function _create_database($filename='') { // Firebird databases are flat files, so a path is required // Hostname is needed for remote access @@ -59,7 +59,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * - the current db is dropped * @return bool */ - public function _drop_database($name='') + protected function _drop_database($name='') { return ibase_drop_db($this->conn_id); } @@ -75,7 +75,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return string */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -171,7 +171,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * * @return string */ - public function _drop_table($table) + protected function _drop_table($table) { return 'DROP TABLE '.$name; } @@ -193,7 +193,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return string */ - public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); @@ -233,7 +233,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); } diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index e1332ba93..7a3a41f2c 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -144,7 +144,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return array */ - public function _data_seek($n = 0) + protected function _data_seek($n = 0) { //Set the row count to 0 $this->num_rows = 0; @@ -162,7 +162,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return array */ - public function _fetch_assoc() + protected function _fetch_assoc() { //Increment row count $this->num_rows++; @@ -179,7 +179,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return object */ - public function _fetch_object() + protected function _fetch_object() { //Increment row count $this->num_rows++; -- cgit v1.2.3-24-g4f1b From 2da66edce7c249c0305153a65c4292311f49a546 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 17:54:39 -0500 Subject: Fix counting issue, minor formatting --- .../database/drivers/interbase/interbase_forge.php | 2 +- .../drivers/interbase/interbase_result.php | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index c7372a0bf..d21a5551b 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -79,7 +79,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $sql = 'CREATE TABLE '; - $sql .= $this->db->_escape_identifiers($table)."("; + $sql .= $this->db->_protect_identifiers($table)."("; $current_field_count = 0; foreach ($fields as $field=>$attributes) diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 7a3a41f2c..9caf1ce91 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -82,7 +82,7 @@ class CI_DB_interbase_result extends CI_DB_result { public function list_fields() { $field_names = array(); - for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) + for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); $field_names[] = $info['name']; @@ -104,7 +104,7 @@ class CI_DB_interbase_result extends CI_DB_result { { $retval = array(); - for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) + for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); @@ -164,10 +164,13 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_assoc() { - //Increment row count - $this->num_rows++; + if(($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + { + //Increment row count + $this->num_rows++; + } - return @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS); + return $row; } // -------------------------------------------------------------------- @@ -181,10 +184,13 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_object() { - //Increment row count - $this->num_rows++; + if(($row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + { + //Increment row count + $this->num_rows++; + } - return @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS); + return $row; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 41a439bf75bdd277e153d44788b732cf2e8c7ee3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 18:40:00 -0500 Subject: Minor formatting fixes --- system/database/drivers/interbase/interbase_result.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 9caf1ce91..01f0e52b2 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -164,7 +164,7 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_assoc() { - if(($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + if (($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) { //Increment row count $this->num_rows++; @@ -184,7 +184,7 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_object() { - if(($row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + if (($row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) { //Increment row count $this->num_rows++; @@ -209,7 +209,7 @@ class CI_DB_interbase_result extends CI_DB_result { // Convert result array to object so that // We don't have to get the result again - if(count($this->result_array) > 0) + if (count($this->result_array) > 0) { $i = 0; @@ -261,7 +261,7 @@ class CI_DB_interbase_result extends CI_DB_result { // Since the object and array are really similar, just case // the result object to an array if need be - if(count($this->result_object) > 0) + if (count($this->result_object) > 0) { foreach($this->result_object as $obj) { -- cgit v1.2.3-24-g4f1b From dd044b317fc2db52f3812792a256497a2f0e94fb Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 18:58:24 -0500 Subject: More style fixes, replaced _protect_identifiers with protect_identifiers in db_forge --- system/database/drivers/interbase/interbase_forge.php | 16 ++++++++-------- system/database/drivers/interbase/interbase_result.php | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index d21a5551b..b8ea6a05d 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -79,7 +79,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $sql = 'CREATE TABLE '; - $sql .= $this->db->_protect_identifiers($table)."("; + $sql .= $this->db->protect_identifiers($table)."("; $current_field_count = 0; foreach ($fields as $field=>$attributes) @@ -95,7 +95,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $sql .= ' '.$attributes['TYPE']; @@ -138,7 +138,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } @@ -148,11 +148,11 @@ class CI_DB_interbase_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")"; @@ -195,7 +195,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { */ protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table)." $alter_type ".$this->db->protect_identifiers($column_name); $sql .= " {$column_definition}"; @@ -215,7 +215,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + $sql .= ' AFTER ' . $this->db->protect_identifiers($after_field); } return $sql; @@ -235,7 +235,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { */ protected function _rename_table($table_name, $new_table_name) { - return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 01f0e52b2..be9cb6547 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -213,11 +213,11 @@ class CI_DB_interbase_result extends CI_DB_result { { $i = 0; - foreach($this->result_array as $array) + foreach ($this->result_array as $array) { $this->result_object[$i] = new StdClass(); - foreach($array as $key => $val) + foreach ($array as $key => $val) { $this->result_object[$i]->{$key} = $val; } @@ -263,7 +263,7 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if (count($this->result_object) > 0) { - foreach($this->result_object as $obj) + foreach ($this->result_object as $obj) { $this->result_array[] = (array)$obj; } -- cgit v1.2.3-24-g4f1b From 2062a8693e1ba44c4530254f63c3936894aad526 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 19:38:10 -0500 Subject: Made tranaaction functions return their actual value --- system/database/drivers/interbase/interbase_driver.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index ba4f9d8d9..7258e605e 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -224,9 +224,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_commit($this->trans); - - return TRUE; + return @ibase_commit($this->trans); } // -------------------------------------------------------------------- @@ -249,9 +247,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_rollback($this->trans); - - return TRUE; + return @ibase_rollback($this->trans); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 125fe732c09f82a0702f29c9309f726bdd5a33c3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 21 Feb 2012 07:58:25 -0500 Subject: More formatting fixes --- system/database/drivers/interbase/interbase_driver.php | 4 ++-- system/database/drivers/interbase/interbase_forge.php | 2 +- system/database/drivers/interbase/interbase_result.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 7258e605e..33038ad80 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -299,8 +299,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * @param string $generator_name - * @param integer $inc_by + * @param string $generator_name + * @param integer $inc_by * @return integer */ public function insert_id($generator_name, $inc_by=0) diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index b8ea6a05d..023d278ce 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -82,7 +82,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { $sql .= $this->db->protect_identifiers($table)."("; $current_field_count = 0; - foreach ($fields as $field=>$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index be9cb6547..4b15eee20 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -265,7 +265,7 @@ class CI_DB_interbase_result extends CI_DB_result { { foreach ($this->result_object as $obj) { - $this->result_array[] = (array)$obj; + $this->result_array[] = (array) $obj; } return $this->result_array; -- cgit v1.2.3-24-g4f1b From 11454e039fd82f2fd4ee2f186ad0317e3435f187 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 22 Feb 2012 16:05:47 +0200 Subject: Add an optional database name parameter to db_select() --- system/database/drivers/mssql/mssql_driver.php | 10 +++++----- system/database/drivers/mysql/mysql_driver.php | 5 +++-- system/database/drivers/mysqli/mysqli_driver.php | 5 +++-- system/database/drivers/sqlsrv/sqlsrv_driver.php | 10 +++++----- 4 files changed, 16 insertions(+), 14 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 2a1098932..27b492f96 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -114,14 +114,14 @@ class CI_DB_mssql_driver extends CI_DB { /** * Select the database * - * @access private called by the base class - * @return resource + * @param string database name + * @return bool */ - function db_select() + public function db_select($database = '') { // Note: The brackets are required in the event that the DB name // contains reserved characters - return @mssql_select_db('['.$this->database.']', $this->conn_id); + return @mssql_select_db('['.($database == '' ? $this->database : $database).']', $this->conn_id); } // -------------------------------------------------------------------- @@ -676,4 +676,4 @@ class CI_DB_mssql_driver extends CI_DB { /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 067710ff0..207a68f14 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -119,11 +119,12 @@ class CI_DB_mysql_driver extends CI_DB { /** * Select the database * + * @param string database name * @return bool */ - public function db_select() + public function db_select($database = '') { - return @mysql_select_db($this->database, $this->conn_id); + return @mysql_select_db(($database == '' ? $this->database : $database), $this->conn_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index a79b2a4ad..0b80f55be 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -119,11 +119,12 @@ class CI_DB_mysqli_driver extends CI_DB { /** * Select the database * + * @param string database name * @return bool */ - public function db_select() + public function db_select($database = '') { - return @mysqli_select_db($this->conn_id, $this->database); + return @mysqli_select_db($this->conn_id, ($database == '' ? $this->database : $database)); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 6fd52ef70..390840094 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -122,12 +122,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Select the database * - * @access private called by the base class - * @return resource + * @param string database name + * @return bool */ - function db_select() + public function db_select($database = '') { - return $this->_execute('USE ' . $this->database); + return $this->_execute('USE '.($database == '' ? $this->database : $database)); } // -------------------------------------------------------------------- @@ -608,4 +608,4 @@ class CI_DB_sqlsrv_driver extends CI_DB { /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ -- cgit v1.2.3-24-g4f1b From ab189e162f20f1a7daae8bfd2b921e694c3f9df3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 22 Feb 2012 10:34:23 -0500 Subject: Close services after using them, added dbutil->backup() method --- .../database/drivers/interbase/interbase_driver.php | 3 +++ .../database/drivers/interbase/interbase_utility.php | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 33038ad80..b49d1fa74 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -139,6 +139,9 @@ class CI_DB_interbase_driver extends CI_DB { if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) { $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); + + // Don't keep the service open + ibase_service_detach($service); return $version; } diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index e31021acb..76a0497c1 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -90,14 +90,24 @@ class CI_DB_interbase_utility extends CI_DB_utility { /** * Interbase/Firebird Export * - * @param array Preferences + * @param string $filename * @return mixed */ - public function _backup($params = array()) + public function backup($filename) { - // Currently unsupported - // @todo See if can be implemented - return $this->db->display_error('db_unsuported_feature'); + if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password)) + { + $res = ibase_backup($service, $this->db->database, $filename.'.fbk'); + + //Close the service connection + ibase_service_detach($service); + + return $res; + } + else + { + return FALSE; + } } } -- cgit v1.2.3-24-g4f1b From 82e8ac19d0ffeb3edd56b09d7a272d13903af7cc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 22 Feb 2012 19:35:34 +0200 Subject: Fix issue 1070 --- system/database/DB_driver.php | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index b829bbe46..271a70ec4 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -107,11 +107,9 @@ class CI_DB_driver { /** * Initialize Database Settings * - * @access private Called by the constructor - * @param mixed - * @return void + * @return bool */ - function initialize() + public function initialize() { // If an existing connection resource is available // there is no need to connect and select the database @@ -125,7 +123,7 @@ class CI_DB_driver { // Connect to the database and set the connection ID $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); - // No connection resource? Check if there is a failover else throw an error + // No connection resource? Check if there is a failover else throw an error if ( ! $this->conn_id) { // Check if there is a failover set @@ -167,31 +165,19 @@ class CI_DB_driver { // ---------------------------------------------------------------- // Select the DB... assuming a database name is specified in the config file - if ($this->database != '') + if ($this->database !== '' && ! $this->db_select()) { - if ( ! $this->db_select()) - { - log_message('error', 'Unable to select database: '.$this->database); + log_message('error', 'Unable to select database: '.$this->database); - if ($this->db_debug) - { - $this->display_error('db_unable_to_select', $this->database); - } - return FALSE; - } - else + if ($this->db_debug) { - // We've selected the DB. Now we set the character set - if ( ! $this->db_set_charset($this->char_set, $this->dbcollat)) - { - return FALSE; - } - - return TRUE; + $this->display_error('db_unable_to_select', $this->database); } + return FALSE; } - return TRUE; + // Now we set the character set and that's all + return $this->db_set_charset($this->char_set, $this->dbcollat); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From c15e17c3fe6110a4e08a56cde3514c02359fe080 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Thu, 23 Feb 2012 14:56:18 -0500 Subject: added all_flashdata function to Session.php --- system/libraries/Session.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 66b39a6a2..a594d24ef 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -468,6 +468,29 @@ class CI_Session { { return $this->userdata; } + + // -------------------------------------------------------------------------- + + /** + * Fetch all flashdata + * + * @return array + */ + public function all_flashdata() + { + $out = array(); + + // loop through all userdata + foreach ($this->all_userdata() as $key => $val) + { + // if it contains flashdata, add it + if (strpos($key, 'flash:old:') !== FALSE) + { + $out[$key] = $val; + } + } + return $out; + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 64d72b1b85efd3810a036b54d40d36ade6cd9f86 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Thu, 23 Feb 2012 15:07:21 -0500 Subject: removed active_rec change. --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 429f65186..424735157 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -988,7 +988,7 @@ class CI_DB_active_record extends CI_DB_driver { */ public function limit($value, $offset = NULL) { - $this->ar_limit = $value; + $this->ar_limit = (int) $value; if ( ! is_null($offset)) { -- cgit v1.2.3-24-g4f1b From 024ba2dffd49e26f68468acd69feebd685f63f68 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 24 Feb 2012 11:40:36 +0200 Subject: Update database property when switching to a new one --- system/database/drivers/mssql/mssql_driver.php | 13 ++++++++++++- system/database/drivers/mysql/mysql_driver.php | 13 ++++++++++++- system/database/drivers/mysqli/mysqli_driver.php | 13 ++++++++++++- system/database/drivers/sqlsrv/sqlsrv_driver.php | 13 ++++++++++++- 4 files changed, 48 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 27b492f96..25a32f364 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -119,9 +119,20 @@ class CI_DB_mssql_driver extends CI_DB { */ public function db_select($database = '') { + if ($database === '') + { + $database = $this->database; + } + // Note: The brackets are required in the event that the DB name // contains reserved characters - return @mssql_select_db('['.($database == '' ? $this->database : $database).']', $this->conn_id); + if (@mssql_select_db('['.$database.']', $this->conn_id)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 207a68f14..c88a8a766 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -124,7 +124,18 @@ class CI_DB_mysql_driver extends CI_DB { */ public function db_select($database = '') { - return @mysql_select_db(($database == '' ? $this->database : $database), $this->conn_id); + if ($database === '') + { + $database = $this->database; + } + + if (@mysql_select_db($database, $this->conn_id)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 0b80f55be..dbba12e15 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -124,7 +124,18 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function db_select($database = '') { - return @mysqli_select_db($this->conn_id, ($database == '' ? $this->database : $database)); + if ($database === '') + { + $database = $this->database; + } + + if (@mysqli_select_db($this->conn_id, $database)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 390840094..9c50209ec 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -127,7 +127,18 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ public function db_select($database = '') { - return $this->_execute('USE '.($database == '' ? $this->database : $database)); + if ($database === '') + { + $database = $this->database; + } + + if ($this->_execute('USE '.$database)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From ceec45609be0ebc2319e9e21a25eb1642f4eef06 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 09:25:49 -0500 Subject: fixed active record inconsistency. --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 429f65186..424735157 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -988,7 +988,7 @@ class CI_DB_active_record extends CI_DB_driver { */ public function limit($value, $offset = NULL) { - $this->ar_limit = $value; + $this->ar_limit = (int) $value; if ( ! is_null($offset)) { -- cgit v1.2.3-24-g4f1b From 46e3a9a365e6bae7954f5118db1409faa5f5decd Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 09:38:35 -0500 Subject: added config check, changelog entry, and user guide update. --- system/libraries/Table.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index fb154e50f..de5a6ba3a 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -49,9 +49,23 @@ class CI_Table { public $empty_cells = ''; public $function = FALSE; - public function __construct() + // -------------------------------------------------------------------------- + + /** + * Set the template from the table config file if it exists + * + * @param array $config (default: array()) + * @return void + */ + public function __construct($config = array()) { log_message('debug', "Table Class Initialized"); + + // initialize config + foreach ($config as $key => $val) + { + $this->template[$key] = $val; + } } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 326a5e75db1e03e453f488f2d612b0f421806129 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 10:06:28 -0500 Subject: added config process method checking for delimiter values, updated changelog and user guide. --- system/libraries/Form_validation.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..93ec8b34a 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -55,6 +55,9 @@ class CI_Form_validation { { $this->CI =& get_instance(); + // applies delimiters set in config file. + $this->_config_delimiters(); + // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -69,6 +72,27 @@ class CI_Form_validation { log_message('debug', "Form Validation Class Initialized"); } + + // -------------------------------------------------------------------- + + /** + * if prefixes/suffixes set in config, assign and unset. + * + * @return void + */ + private function _config_delimiters() + { + if (isset($rules['error_prefix'])) + { + $this->_error_prefix = $rules['error_prefix']); + unset $rules['error_prefix']); + } + if (isset($rules['error_suffix'])) + { + $this->_error_suffix = $rules['error_suffix']); + unset $rules['error_suffix']); + } + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 063f5963b01f9c19a2ed070d9e3aa077a2515c21 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 27 Feb 2012 12:20:52 +0200 Subject: Fixed a db_set_charset() bug --- system/database/DB_driver.php | 11 +++++------ system/database/drivers/cubrid/cubrid_driver.php | 20 +------------------- system/database/drivers/mssql/mssql_driver.php | 16 ---------------- system/database/drivers/oci8/oci8_driver.php | 16 ---------------- system/database/drivers/odbc/odbc_driver.php | 18 +----------------- system/database/drivers/pdo/pdo_driver.php | 17 +---------------- system/database/drivers/postgre/postgre_driver.php | 18 +----------------- system/database/drivers/sqlite/sqlite_driver.php | 18 +----------------- system/database/drivers/sqlsrv/sqlsrv_driver.php | 16 ---------------- 9 files changed, 10 insertions(+), 140 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 271a70ec4..f1e9e7239 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -185,20 +185,19 @@ class CI_DB_driver { /** * Set client character set * - * @access public * @param string * @param string - * @return resource + * @return bool */ - function db_set_charset($charset, $collation) + public function db_set_charset($charset, $collation = '') { - if ( ! $this->_db_set_charset($this->char_set, $this->dbcollat)) + if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset, $collation)) { - log_message('error', 'Unable to set database connection charset: '.$this->char_set); + log_message('error', 'Unable to set database connection charset: '.$charset); if ($this->db_debug) { - $this->display_error('db_unable_to_set_charset', $this->char_set); + $this->display_error('db_unable_to_set_charset', $charset); } return FALSE; diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index cde719eae..a589ded0c 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -155,24 +155,6 @@ class CI_DB_cubrid_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - // In CUBRID, there is no need to set charset or collation. - // This is why returning true will allow the application continue - // its normal process. - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * @@ -801,4 +783,4 @@ class CI_DB_cubrid_driver extends CI_DB { /* End of file cubrid_driver.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 25a32f364..2a4f2b575 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -137,22 +137,6 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - // @todo - add support if needed - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Execute the query * diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index c6621901b..292ccd0fd 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -138,22 +138,6 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - public function db_set_charset($charset, $collation) - { - // this is done upon connect - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 6ba39f0cd..abb660324 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -123,22 +123,6 @@ class CI_DB_odbc_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - // @todo - add support if needed - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * @@ -646,4 +630,4 @@ class CI_DB_odbc_driver extends CI_DB { /* End of file odbc_driver.php */ -/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/odbc/odbc_driver.php */ diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index de2b0abeb..fea54e502 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -288,21 +288,6 @@ class CI_DB_pdo_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * @@ -950,4 +935,4 @@ class CI_DB_pdo_driver extends CI_DB { } /* End of file pdo_driver.php */ -/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/pdo/pdo_driver.php */ diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 42329bded..89541e5fa 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -146,22 +146,6 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - // @todo - add support if needed - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * @@ -712,4 +696,4 @@ class CI_DB_postgre_driver extends CI_DB { /* End of file postgre_driver.php */ -/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/postgre/postgre_driver.php */ diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 28c3caecd..718501b20 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -140,22 +140,6 @@ class CI_DB_sqlite_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - // @todo - add support if needed - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * @@ -667,4 +651,4 @@ class CI_DB_sqlite_driver extends CI_DB { /* End of file sqlite_driver.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 9c50209ec..ba886f1fe 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -143,22 +143,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - // @todo - add support if needed - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Execute the query * -- cgit v1.2.3-24-g4f1b From b7b439681f466974dbb2533b70eaa230a40908c0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 27 Feb 2012 22:45:48 +0200 Subject: Just some style changes and removed a useless check --- system/core/Common.php | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'system') diff --git a/system/core/Common.php b/system/core/Common.php index 225227d17..491979350 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -56,7 +56,7 @@ if ( ! function_exists('is_php')) function is_php($version = '5.0.0') { static $_is_php; - $version = (string)$version; + $version = (string) $version; if ( ! isset($_is_php[$version])) { @@ -84,7 +84,7 @@ if ( ! function_exists('is_really_writable')) function is_really_writable($file) { // If we're on a Unix server with safe_mode off we call is_writable - if (DIRECTORY_SEPARATOR === '/' AND @ini_get('safe_mode') == FALSE) + if (DIRECTORY_SEPARATOR === '/' && (bool) @ini_get('safe_mode') === FALSE) { return is_writable($file); } @@ -120,7 +120,7 @@ if ( ! function_exists('is_really_writable')) /** * Class registry * -* This function acts as a singleton. If the requested class does not +* This function acts as a singleton. If the requested class does not * exist it is instantiated and set to a static variable. If it has * previously been instantiated the variable is returned. * @@ -192,7 +192,7 @@ if ( ! function_exists('load_class')) // -------------------------------------------------------------------- /** -* Keeps track of which libraries have been loaded. This function is +* Keeps track of which libraries have been loaded. This function is * called by the load_class() function above * * @access public @@ -437,7 +437,7 @@ if ( ! function_exists('set_status_header')) show_error('Status codes must be numeric', 500); } - if (isset($stati[$code]) AND $text == '') + if (isset($stati[$code]) && $text == '') { $text = $stati[$code]; } @@ -447,19 +447,19 @@ if ( ! function_exists('set_status_header')) show_error('No status text available. Please check your status code number or supply your own message text.', 500); } - $server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; + $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; if (strpos(php_sapi_name(), 'cgi') === 0) { - header("Status: {$code} {$text}", TRUE); + header('Status: '.$code.' '.$text, TRUE); } - elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0') + elseif ($server_protocol === 'HTTP/1.0') { - header($server_protocol." {$code} {$text}", TRUE, $code); + header('HTTP/1.0 '.$code.' '.$text, TRUE, $code); } else { - header("HTTP/1.1 {$code} {$text}", TRUE, $code); + header('HTTP/1.1 '.$code.' '.$text, TRUE, $code); } } } @@ -564,14 +564,9 @@ if ( ! function_exists('html_escape')) { function html_escape($var) { - if (is_array($var)) - { - return array_map('html_escape', $var); - } - else - { - return htmlspecialchars($var, ENT_QUOTES, config_item('charset')); - } + return is_array($var) + ? array_map('html_escape', $var) + : htmlspecialchars($var, ENT_QUOTES, config_item('charset')); } } -- cgit v1.2.3-24-g4f1b From 67ccdc02e1b66750b0e13eadcfacc47f01c1de67 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 27 Feb 2012 23:57:58 +0200 Subject: Do not create a CSRF cookie if CSRF protection is not enabled --- system/core/Security.php | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'system') diff --git a/system/core/Security.php b/system/core/Security.php index 1007f61f4..688aeba33 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Security Class * @@ -106,23 +104,27 @@ class CI_Security { public function __construct() { - // CSRF config - foreach(array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key) + // Is CSRF protection enabled? + if (config_item('csrf_protection') === TRUE) { - if (FALSE !== ($val = config_item($key))) + // CSRF config + foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key) { - $this->{'_'.$key} = $val; + if (FALSE !== ($val = config_item($key))) + { + $this->{'_'.$key} = $val; + } } - } - // Append application specific cookie prefix - if (config_item('cookie_prefix')) - { - $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name; - } + // Append application specific cookie prefix + if (config_item('cookie_prefix')) + { + $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name; + } - // Set the CSRF hash - $this->_csrf_set_hash(); + // Set the CSRF hash + $this->_csrf_set_hash(); + } log_message('debug', 'Security Class Initialized'); } @@ -189,7 +191,7 @@ class CI_Security { $expire = time() + $this->_csrf_expire; $secure_cookie = (bool) config_item('cookie_secure'); - if ($secure_cookie && ( ! isset($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] == 'off' OR ! $_SERVER['HTTPS'])) + if ($secure_cookie && (empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off')) { return FALSE; } @@ -358,7 +360,7 @@ class CI_Security { foreach ($words as $word) { - $word = implode("\s*", str_split($word)) . "\s*"; + $word = implode('\s*', str_split($word)).'\s*'; // We only want to do this when it is followed by a non-word character // That way valid stuff like "dealer to" does not become "dealerto" @@ -425,7 +427,6 @@ class CI_Security { '\\1\\2(\\3)', $str); - // Final clean up // This adds a bit of extra precaution in case // something got through the above filters @@ -601,7 +602,7 @@ class CI_Security { } // find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes) - preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is', $str, $matches, PREG_SET_ORDER); + preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is', $str, $matches, PREG_SET_ORDER); foreach ($matches as $attr) { @@ -633,7 +634,7 @@ class CI_Security { { return '<'.$matches[1].$matches[2].$matches[3] // encode opening brace // encode captured opening or closing brace to prevent recursive vectors: - . str_replace(array('>', '<'), array('>', '<'), $matches[4]); + .str_replace(array('>', '<'), array('>', '<'), $matches[4]); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 08c7c62b57b0d6d8f126e8629b8e8da71bd9636f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Feb 2012 13:23:38 +0200 Subject: Fix escape_like_str() --- system/database/drivers/oci8/oci8_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 3c70ccd9f..007e56a0b 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -477,8 +477,8 @@ class CI_DB_oci8_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - return str_replace(array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), + return str_replace(array($this->_like_escape_chr.$this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), $str); } -- cgit v1.2.3-24-g4f1b From 46ac881006b1215e136a875491efb020c59246fb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Feb 2012 14:32:54 +0200 Subject: Fix issue #177 --- system/libraries/Form_validation.php | 42 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..4c393c1d5 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -703,11 +703,11 @@ class CI_Form_validation { * * @param string the field name * @param string - * @return void + * @return string */ public function set_value($field = '', $default = '') { - if ( ! isset($this->_field_data[$field])) + if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { return $default; } @@ -736,13 +736,9 @@ class CI_Form_validation { */ public function set_select($field = '', $value = '', $default = FALSE) { - if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) + if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' selected="selected"'; - } - return ''; + return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -754,12 +750,9 @@ class CI_Form_validation { return ''; } } - else + elseif (($field == '' OR $value == '') OR ($field != $value)) { - if (($field == '' OR $value == '') OR ($field != $value)) - { - return ''; - } + return ''; } return ' selected="selected"'; @@ -779,13 +772,9 @@ class CI_Form_validation { */ public function set_radio($field = '', $value = '', $default = FALSE) { - if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) + if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' checked="checked"'; - } - return ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' checked="checked"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -869,9 +858,7 @@ class CI_Form_validation { return FALSE; } - $field = $_POST[$field]; - - return ($str === $field); + return ($str === $_POST[$field]); } // -------------------------------------------------------------------- @@ -908,7 +895,7 @@ class CI_Form_validation { */ public function min_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -932,7 +919,7 @@ class CI_Form_validation { */ public function max_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -956,7 +943,7 @@ class CI_Form_validation { */ public function exact_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -1170,7 +1157,7 @@ class CI_Form_validation { */ public function is_natural_no_zero($str) { - return ($str != 0 AND preg_match('/^[0-9]+$/', $str)); + return ($str != 0 && preg_match('/^[0-9]+$/', $str)); } // -------------------------------------------------------------------- @@ -1217,7 +1204,7 @@ class CI_Form_validation { return $data; } - return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); + return str_replace(array("'", '"', '<', '>'), array(''', '"', '<', '>'), stripslashes($data)); } // -------------------------------------------------------------------- @@ -1283,7 +1270,6 @@ class CI_Form_validation { } } -// END Form Validation Class /* End of file Form_validation.php */ /* Location: ./system/libraries/Form_validation.php */ -- cgit v1.2.3-24-g4f1b From 0adff1bac0617e5d02c7f8028c7fae8fedda9370 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Feb 2012 14:36:40 +0200 Subject: Replace AND with && --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 4c393c1d5..2ee734ae6 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -738,7 +738,7 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { - return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; -- cgit v1.2.3-24-g4f1b From 1ccdb9a8e3a34153d3c9a1075b44e84dd39aa25c Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:32:19 -0500 Subject: changed _config_delimiters() to protected. --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 93ec8b34a..25ccb4c69 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -80,7 +80,7 @@ class CI_Form_validation { * * @return void */ - private function _config_delimiters() + protected function _config_delimiters() { if (isset($rules['error_prefix'])) { -- cgit v1.2.3-24-g4f1b From 9af3337175b82c66e7f43d2ad782e2e1d79dac5e Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:37:56 -0500 Subject: fixed some mismatched brackets. --- system/libraries/Form_validation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 25ccb4c69..bfe64fac9 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -84,13 +84,13 @@ class CI_Form_validation { { if (isset($rules['error_prefix'])) { - $this->_error_prefix = $rules['error_prefix']); - unset $rules['error_prefix']); + $this->_error_prefix = $rules['error_prefix']; + unset($rules['error_prefix']); } if (isset($rules['error_suffix'])) { - $this->_error_suffix = $rules['error_suffix']); - unset $rules['error_suffix']); + $this->_error_suffix = $rules['error_suffix']; + unset($rules['error_suffix']); } } -- cgit v1.2.3-24-g4f1b From aa20f5b70f6da196d1a66d5dc17b05a037708e1a Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:43:16 -0500 Subject: using tabs as @item seperators in docblocks. --- system/libraries/Table.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index de5a6ba3a..947aedd8f 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -54,8 +54,8 @@ class CI_Table { /** * Set the template from the table config file if it exists * - * @param array $config (default: array()) - * @return void + * @param array $config (default: array()) + * @return void */ public function __construct($config = array()) { -- cgit v1.2.3-24-g4f1b From a90b1f2f89a41b2fe061f5fdd3f84f08b961a887 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:44:19 -0500 Subject: tab separator in _config_delimiters dockblock. --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index bfe64fac9..79414656f 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -78,7 +78,7 @@ class CI_Form_validation { /** * if prefixes/suffixes set in config, assign and unset. * - * @return void + * @return void */ protected function _config_delimiters() { -- cgit v1.2.3-24-g4f1b From c91a66cd7c770f8060cbe366491c1f4de9147da4 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:46:00 -0500 Subject: tab separation in docblock. --- system/libraries/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index a594d24ef..c14b11fa3 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -474,7 +474,7 @@ class CI_Session { /** * Fetch all flashdata * - * @return array + * @return array */ public function all_flashdata() { -- cgit v1.2.3-24-g4f1b From b38c5dd95644ed73166df34084041cee0efd7d23 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Feb 2012 14:07:45 +0200 Subject: Add an optional set_mime parameter to force_download() --- system/helpers/download_helper.php | 80 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 39 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index aea948d81..34380cc88 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -1,13 +1,13 @@ - Date: Wed, 29 Feb 2012 12:12:49 +0000 Subject: Improved plural() and singular(). Avoids double-pluralization using "uncountable words" and better logic. --- system/helpers/inflector_helper.php | 152 +++++++++++++++++++++++------------- 1 file changed, 96 insertions(+), 56 deletions(-) (limited to 'system') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 2069a1927..02c425b8a 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -34,7 +34,7 @@ * @subpackage Helpers * @category Helpers * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/helpers/directory_helper.html + * @link http://codeigniter.com/user_guide/helpers/inflector_helper.html */ @@ -45,7 +45,6 @@ * * Takes a plural word and makes it singular * - * @access public * @param string * @return str */ @@ -55,37 +54,51 @@ if ( ! function_exists('singular')) { $result = strval($str); + if ( ! is_countable($result)) + { + return $result; + } + $singular_rules = array( - '/(matr)ices$/' => '\1ix', - '/(vert|ind)ices$/' => '\1ex', - '/^(ox)en/' => '\1', - '/(alias)es$/' => '\1', - '/([octop|vir])i$/' => '\1us', - '/(cris|ax|test)es$/' => '\1is', - '/(shoe)s$/' => '\1', - '/(o)es$/' => '\1', - '/(bus|campus)es$/' => '\1', - '/([m|l])ice$/' => '\1ouse', - '/(x|ch|ss|sh)es$/' => '\1', - '/(m)ovies$/' => '\1\2ovie', - '/(s)eries$/' => '\1\2eries', - '/([^aeiouy]|qu)ies$/' => '\1y', - '/([lr])ves$/' => '\1f', - '/(tive)s$/' => '\1', - '/(hive)s$/' => '\1', - '/([^f])ves$/' => '\1fe', - '/(^analy)ses$/' => '\1sis', + '/(matr)ices$/' => '\1ix', + '/(vert|ind)ices$/' => '\1ex', + '/^(ox)en/' => '\1', + '/(alias)es$/' => '\1', + '/([octop|vir])i$/' => '\1us', + '/(cris|ax|test)es$/' => '\1is', + '/(shoe)s$/' => '\1', + '/(o)es$/' => '\1', + '/(bus|campus)es$/' => '\1', + '/([m|l])ice$/' => '\1ouse', + '/(x|ch|ss|sh)es$/' => '\1', + '/(m)ovies$/' => '\1\2ovie', + '/(s)eries$/' => '\1\2eries', + '/([^aeiouy]|qu)ies$/' => '\1y', + '/([lr])ves$/' => '\1f', + '/(tive)s$/' => '\1', + '/(hive)s$/' => '\1', + '/([^f])ves$/' => '\1fe', + '/(^analy)ses$/' => '\1sis', '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/' => '\1\2sis', - '/([ti])a$/' => '\1um', - '/(p)eople$/' => '\1\2erson', - '/(m)en$/' => '\1an', - '/(s)tatuses$/' => '\1\2tatus', - '/(c)hildren$/' => '\1\2hild', - '/(n)ews$/' => '\1\2ews', - '/([^u])s$/' => '\1', + '/([ti])a$/' => '\1um', + '/(p)eople$/' => '\1\2erson', + '/(m)en$/' => '\1an', + '/(s)tatuses$/' => '\1\2tatus', + '/(c)hildren$/' => '\1\2hild', + '/(n)ews$/' => '\1\2ews', + '/([^us])s$/' => '\1', ); - return preg_replace(array_keys($singular_rules), $singular_rules, $result); + foreach ($singular_rules as $rule => $replacement) + { + if (preg_match($rule, $result)) + { + $result = preg_replace($rule, $replacement, $result); + break; + } + } + + return $result; } } @@ -96,7 +109,6 @@ if ( ! function_exists('singular')) * * Takes a singular word and makes it plural * - * @access public * @param string * @param bool * @return str @@ -104,32 +116,46 @@ if ( ! function_exists('singular')) if ( ! function_exists('plural')) { function plural($str, $force = FALSE) - { + { $result = strval($str); + if ( ! is_countable($result)) + { + return $result; + } + $plural_rules = array( - '/^(ox)$/' => '\1\2en', // ox - '/([m|l])ouse$/' => '\1ice', // mouse, louse - '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index - '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address - '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency - '/(hive)$/' => '\1s', // archive, hive - '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife - '/sis$/' => 'ses', // basis, diagnosis - '/([ti])um$/' => '\1a', // datum, medium - '/(p)erson$/' => '\1eople', // person, salesperson - '/(m)an$/' => '\1en', // man, woman, spokesman - '/(c)hild$/' => '\1hildren', // child - '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato - '/(bu|campu)s$/' => '\1\2ses', // bus, campus - '/(alias|status|virus)/' => '\1es', // alias - '/(octop)us$/' => '\1i', // octopus - '/(ax|cris|test)is$/' => '\1es', // axis, crisis - '/s$/' => 's', // no change (compatibility) - '/$/' => 's', + '/^(ox)$/' => '\1\2en', // ox + '/([m|l])ouse$/' => '\1ice', // mouse, louse + '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index + '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address + '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency + '/(hive)$/' => '\1s', // archive, hive + '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife + '/sis$/' => 'ses', // basis, diagnosis + '/([ti])um$/' => '\1a', // datum, medium + '/(p)erson$/' => '\1eople', // person, salesperson + '/(m)an$/' => '\1en', // man, woman, spokesman + '/(c)hild$/' => '\1hildren', // child + '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato + '/(bu|campu)s$/' => '\1\2ses', // bus, campus + '/(alias|status|virus)$/' => '\1es', // alias + '/(octop)us$/' => '\1i', // octopus + '/(ax|cris|test)is$/' => '\1es', // axis, crisis + '/s$/' => 's', // no change (compatibility) + '/$/' => 's', ); - - return preg_replace(array_keys($plural_rules), $plural_rules, $result); + + foreach ($plural_rules as $rule => $replacement) + { + if (preg_match($rule, $result)) + { + $result = preg_replace($rule, $replacement, $result); + break; + } + } + + return $result; } } @@ -140,7 +166,6 @@ if ( ! function_exists('plural')) * * Takes multiple words separated by spaces or underscores and camelizes them * - * @access public * @param string * @return str */ @@ -159,7 +184,6 @@ if ( ! function_exists('camelize')) * * Takes multiple words separated by spaces and underscores them * - * @access public * @param string * @return str */ @@ -178,7 +202,6 @@ if ( ! function_exists('underscore')) * * Takes multiple words separated by the separator and changes them to spaces * - * @access public * @param string $str * @param string $separator * @return str @@ -191,5 +214,22 @@ if ( ! function_exists('humanize')) } } +/** + * Checks if the given word has a plural version. + * + * @param string the word to check + * @return bool if the word is countable + */ +if ( ! function_exists('is_countable')) +{ + function is_countable($word) + { + return ! (in_array(strtolower(strval($word)), array( + 'equipment', 'information', 'rice', 'money', + 'species', 'series', 'fish', 'meta' + ))); + } +} + /* End of file inflector_helper.php */ -/* Location: ./system/helpers/inflector_helper.php */ +/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b57832690574b913c3224b4407427db00dfe7fed Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 29 Feb 2012 15:40:28 +0100 Subject: removed double slash --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 82383f658..0b853233d 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -960,7 +960,7 @@ class CI_Upload { } elseif (is_file(APPPATH.'config/mimes.php')) { - include(APPPATH.'config//mimes.php'); + include(APPPATH.'config/mimes.php'); } else { -- cgit v1.2.3-24-g4f1b From a10c8e17bbd1eb75aed1bb74523449f81ee393a2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Feb 2012 18:56:12 +0200 Subject: Add strtolower to the HTTPS check --- system/core/Security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Security.php b/system/core/Security.php index 688aeba33..6f25fb5bb 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -191,7 +191,7 @@ class CI_Security { $expire = time() + $this->_csrf_expire; $secure_cookie = (bool) config_item('cookie_secure'); - if ($secure_cookie && (empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off')) + if ($secure_cookie && (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) === 'off')) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 56784f67c35c75b706c5f9fc2950e58356e7ecec Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 29 Feb 2012 11:58:20 -0500 Subject: Finally figured out limit statement --- .../drivers/interbase/interbase_driver.php | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index b49d1fa74..e55a476bb 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -601,7 +601,31 @@ SQL; */ protected function _limit($sql, $limit, $offset) { - //There doesn't seem to be a limit clause? + // Keep the current sql string safe for a moment + $orig_sql = $sql; + + // Limit clause depends on if Interbase or Firebird + if (stripos($this->_version(), 'firebird') !== FALSE) + { + $sql = 'FIRST '. (int) $limit; + + if ($offset > 0) + { + $sql .= ' SKIP'. (int) $offset; + } + } + else + { + $sql = 'ROWS ' . (int) $limit; + + if ($offset > 0) + { + $sql = 'ROWS '. (int) $offset . ' TO ' . ($limit + $offset); + } + } + + $sql = preg_replace("`SELECT`i", "SELECT {$sql}", $orig_sql); + return $sql; } -- cgit v1.2.3-24-g4f1b From db0c06247949a4def38bcb0c0cf1239312140a81 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Feb 2012 19:02:46 +0200 Subject: Change end() usage due to E_STRICT messages --- system/database/DB_active_rec.php | 3 ++- system/helpers/download_helper.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 424735157..eaae23f30 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -236,7 +236,8 @@ class CI_DB_active_record extends CI_DB_driver { { if (strpos($item, '.') !== FALSE) { - return end(explode('.', $item)); + $item = explode('.', $item); + return end($item); } return $item; diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 34380cc88..a8c59c2c0 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -70,7 +70,8 @@ if ( ! function_exists('force_download')) return FALSE; } - $extension = end(explode('.', $filename)); + $extension = explode('.', $filename); + $extension = end($extension); // Load the mime types if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) -- cgit v1.2.3-24-g4f1b From 0b5a4867af78838f3c7e2726e469f904e15976f1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Feb 2012 23:44:00 +0200 Subject: Minor clean-up --- system/libraries/Zip.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 174d18a67..f2f5f2e5d 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -155,7 +155,7 @@ class CI_Zip { * Add Data to Zip * * Lets you add files to the archive. If the path is included - * in the filename it will be placed within a directory. Make + * in the filename it will be placed within a directory. Make * sure you use add_dir() first to create the folder. * * @param mixed @@ -314,7 +314,6 @@ class CI_Zip { } closedir($fp); - return TRUE; } @@ -373,7 +372,7 @@ class CI_Zip { * Download * * @param string the file name - * @return bool + * @return void */ public function download($filename = 'backup.zip') { -- cgit v1.2.3-24-g4f1b From 03a57655f3cdc6c0b9f717f4466a4547247729d3 Mon Sep 17 00:00:00 2001 From: Mike Davies Date: Wed, 29 Feb 2012 17:52:36 -0500 Subject: Added support for Wincache when running CI on Windows boxes Wincache is directly analogous to APC, except with less problems on a Windows environment. Performance wise they are almost identical (for user mode caching at least). Need to have the Wincache PHP module downloaded from http://www.iis.net/download/wincacheforphp. --- system/libraries/Cache/Cache.php | 2 +- system/libraries/Cache/drivers/Cache_wincache.php | 155 ++++++++++++++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 system/libraries/Cache/drivers/Cache_wincache.php (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 2e78a6660..e9cc1101c 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -39,7 +39,7 @@ class CI_Cache extends CI_Driver_Library { protected $valid_drivers = array( - 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy' + 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy', 'cache_wincache' ); protected $_cache_path = NULL; // Path of cache files (if file-based cache) diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php new file mode 100644 index 000000000..a1b1bb3de --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -0,0 +1,155 @@ + $ttl - $age, + 'hitcount' => $hitcount, + 'age' => $age, + 'ttl' => $ttl + ); + } + return false; + } + + // ------------------------------------------------------------------------ + + /** + * is_supported() + * + * Check to see if WinCache is available on this system, bail if it isn't. + */ + public function is_supported() + { + if ( ! extension_loaded('wincache') ) + { + log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); + return FALSE; + } + + return TRUE; + } + + // ------------------------------------------------------------------------ + + +} +// End Class + +/* End of file Cache_wincache.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ -- cgit v1.2.3-24-g4f1b From 9a96082726feadadd50aef1287b4e0df61414c0d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 29 Feb 2012 22:53:35 -0500 Subject: Fix 'skip' section of limit clause --- system/database/drivers/interbase/interbase_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index e55a476bb..4dca7c8a9 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -611,7 +611,7 @@ SQL; if ($offset > 0) { - $sql .= ' SKIP'. (int) $offset; + $sql .= ' SKIP '. (int) $offset; } } else -- cgit v1.2.3-24-g4f1b From 50814099c41321e74b7aa7a451f23890fa7d20a1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 12:36:12 +0200 Subject: Switch private properties in the Email class to protected --- system/libraries/Email.php | 49 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 922107e9f..027ec0adb 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -64,30 +64,31 @@ class CI_Email { public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch - private $_safe_mode = FALSE; - private $_subject = ""; - private $_body = ""; - private $_finalbody = ""; - private $_alt_boundary = ""; - private $_atc_boundary = ""; - private $_header_str = ""; - private $_smtp_connect = ""; - private $_encoding = "8bit"; - private $_IP = FALSE; - private $_smtp_auth = FALSE; - private $_replyto_flag = FALSE; - private $_debug_msg = array(); - private $_recipients = array(); - private $_cc_array = array(); - private $_bcc_array = array(); - private $_headers = array(); - private $_attach_name = array(); - private $_attach_type = array(); - private $_attach_disp = array(); - private $_protocols = array('mail', 'sendmail', 'smtp'); - private $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) - private $_bit_depths = array('7bit', '8bit'); - private $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); + + protected $_safe_mode = FALSE; + protected $_subject = ''; + protected $_body = ''; + protected $_finalbody = ''; + protected $_alt_boundary = ''; + protected $_atc_boundary = ''; + protected $_header_str = ''; + protected $_smtp_connect = ''; + protected $_encoding = '8bit'; + protected $_IP = FALSE; + protected $_smtp_auth = FALSE; + protected $_replyto_flag = FALSE; + protected $_debug_msg = array(); + protected $_recipients = array(); + protected $_cc_array = array(); + protected $_bcc_array = array(); + protected $_headers = array(); + protected $_attach_name = array(); + protected $_attach_type = array(); + protected $_attach_disp = array(); + protected $_protocols = array('mail', 'sendmail', 'smtp'); + protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) + protected $_bit_depths = array('7bit', '8bit'); + protected $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); /** -- cgit v1.2.3-24-g4f1b From 081c946bf049a013aaeab4dc726cdbbe20473eb2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 12:58:11 +0200 Subject: Remove access lines and fix method description blocks in the Email class --- system/libraries/Email.php | 109 +++++++++++---------------------------------- 1 file changed, 25 insertions(+), 84 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 027ec0adb..898effeb6 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Email Class * @@ -90,7 +88,6 @@ class CI_Email { protected $_bit_depths = array('7bit', '8bit'); protected $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); - /** * Constructor - Sets Email Preferences * @@ -116,7 +113,6 @@ class CI_Email { /** * Initialize preferences * - * @access public * @param array * @return void */ @@ -151,9 +147,8 @@ class CI_Email { /** * Initialize the Email Data * - * @access public * @param bool - * @return void + * @return object */ public function clear($clear_attachments = FALSE) { @@ -186,10 +181,9 @@ class CI_Email { /** * Set FROM * - * @access public * @param string * @param string - * @return void + * @return object */ public function from($from, $name = '') { @@ -229,10 +223,9 @@ class CI_Email { /** * Set Reply-to * - * @access public * @param string * @param string - * @return void + * @return object */ public function reply_to($replyto, $name = '') { @@ -267,9 +260,8 @@ class CI_Email { /** * Set Recipients * - * @access public * @param string - * @return void + * @return object */ public function to($to) { @@ -305,9 +297,8 @@ class CI_Email { /** * Set CC * - * @access public * @param string - * @return void + * @return object */ public function cc($cc) { @@ -334,10 +325,9 @@ class CI_Email { /** * Set BCC * - * @access public * @param string * @param string - * @return void + * @return object */ public function bcc($bcc, $limit = '') { @@ -372,9 +362,8 @@ class CI_Email { /** * Set Email Subject * - * @access public * @param string - * @return void + * @return object */ public function subject($subject) { @@ -388,9 +377,8 @@ class CI_Email { /** * Set Body * - * @access public * @param string - * @return void + * @return object */ public function message($body) { @@ -415,9 +403,8 @@ class CI_Email { /** * Assign file attachments * - * @access public * @param string - * @return void + * @return object */ public function attach($filename, $disposition = '', $newname = NULL) { @@ -432,7 +419,6 @@ class CI_Email { /** * Add a Header Item * - * @access protected * @param string * @param string * @return void @@ -447,7 +433,6 @@ class CI_Email { /** * Convert a String to an Array * - * @access protected * @param string * @return array */ @@ -473,9 +458,8 @@ class CI_Email { /** * Set Multipart Value * - * @access public * @param string - * @return void + * @return object */ public function set_alt_message($str = '') { @@ -488,9 +472,8 @@ class CI_Email { /** * Set Mailtype * - * @access public * @param string - * @return void + * @return object */ public function set_mailtype($type = 'text') { @@ -503,9 +486,8 @@ class CI_Email { /** * Set Wordwrap * - * @access public * @param bool - * @return void + * @return object */ public function set_wordwrap($wordwrap = TRUE) { @@ -518,9 +500,8 @@ class CI_Email { /** * Set Protocol * - * @access public * @param string - * @return void + * @return object */ public function set_protocol($protocol = 'mail') { @@ -533,9 +514,8 @@ class CI_Email { /** * Set Priority * - * @access public - * @param integer - * @return void + * @param int + * @return object */ public function set_priority($n = 3) { @@ -554,9 +534,8 @@ class CI_Email { /** * Set Newline Character * - * @access public * @param string - * @return void + * @return object */ public function set_newline($newline = "\n") { @@ -569,9 +548,8 @@ class CI_Email { /** * Set CRLF * - * @access public * @param string - * @return void + * @return object */ public function set_crlf($crlf = "\n") { @@ -584,7 +562,6 @@ class CI_Email { /** * Set Message Boundary * - * @access protected * @return void */ protected function _set_boundaries() @@ -598,7 +575,6 @@ class CI_Email { /** * Get the Message ID * - * @access protected * @return string */ protected function _get_message_id() @@ -613,7 +589,6 @@ class CI_Email { /** * Get Mail Protocol * - * @access protected * @param bool * @return string */ @@ -633,7 +608,6 @@ class CI_Email { /** * Get Mail Encoding * - * @access protected * @param bool * @return string */ @@ -660,7 +634,6 @@ class CI_Email { /** * Get content type (text/html/attachment) * - * @access protected * @return string */ protected function _get_content_type() @@ -688,7 +661,6 @@ class CI_Email { /** * Set RFC 822 Date * - * @access protected * @return string */ protected function _set_date() @@ -706,7 +678,6 @@ class CI_Email { /** * Mime message * - * @access protected * @return string */ protected function _get_mime_message() @@ -719,7 +690,6 @@ class CI_Email { /** * Validate Email Address * - * @access public * @param string * @return bool */ @@ -748,7 +718,6 @@ class CI_Email { /** * Email Validation * - * @access public * @param string * @return bool */ @@ -762,7 +731,6 @@ class CI_Email { /** * Clean Extended Email Address: Joe Smith * - * @access public * @param string * @return string */ @@ -793,7 +761,6 @@ class CI_Email { * If the user hasn't specified his own alternative message * it creates one by stripping the HTML * - * @access protected * @return string */ protected function _get_alt_message() @@ -819,9 +786,8 @@ class CI_Email { /** * Word Wrap * - * @access public * @param string - * @param integer + * @param int * @return string */ public function word_wrap($str, $charlim = '') @@ -912,8 +878,6 @@ class CI_Email { /** * Build final headers * - * @access protected - * @param string * @return string */ protected function _build_headers() @@ -930,7 +894,6 @@ class CI_Email { /** * Write Headers as a string * - * @access protected * @return void */ protected function _write_headers() @@ -965,7 +928,6 @@ class CI_Email { /** * Build Final Body and attachments * - * @access protected * @return void */ protected function _build_message() @@ -1132,9 +1094,8 @@ class CI_Email { * Prepares string for Quoted-Printable Content-Transfer-Encoding * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt * - * @access protected * @param string - * @param integer + * @param int * @return string */ protected function _prep_quoted_printable($str, $charlim = '') @@ -1217,10 +1178,9 @@ class CI_Email { * Performs "Q Encoding" on a string for use in email headers. It's related * but not identical to quoted-printable, so it has its own method * - * @access public - * @param str - * @param bool // set to TRUE for processing From: headers - * @return str + * @param string + * @param bool set to TRUE for processing From: headers + * @return string */ protected function _prep_q_encoding($str, $from = FALSE) { @@ -1286,7 +1246,6 @@ class CI_Email { /** * Send Email * - * @access public * @return bool */ public function send() @@ -1319,10 +1278,9 @@ class CI_Email { // -------------------------------------------------------------------- /** - * Batch Bcc Send. Sends groups of BCCs in batches + * Batch Bcc Send. Sends groups of BCCs in batches * - * @access public - * @return bool + * @return void */ public function batch_bcc_send() { @@ -1377,7 +1335,6 @@ class CI_Email { /** * Unwrap special elements * - * @access protected * @return void */ protected function _unwrap_specials() @@ -1390,7 +1347,6 @@ class CI_Email { /** * Strip line-breaks via callback * - * @access protected * @return string */ protected function _remove_nl_callback($matches) @@ -1408,7 +1364,6 @@ class CI_Email { /** * Spool mail to the mail server * - * @access protected * @return bool */ protected function _spool_email() @@ -1430,7 +1385,6 @@ class CI_Email { /** * Send using mail() * - * @access protected * @return bool */ protected function _send_with_mail() @@ -1452,7 +1406,6 @@ class CI_Email { /** * Send using Sendmail * - * @access protected * @return bool */ protected function _send_with_sendmail() @@ -1485,7 +1438,6 @@ class CI_Email { /** * Send using SMTP * - * @access protected * @return bool */ protected function _send_with_smtp() @@ -1554,7 +1506,6 @@ class CI_Email { /** * SMTP Connect * - * @access protected * @param string * @return string */ @@ -1598,7 +1549,6 @@ class CI_Email { /** * Send SMTP command * - * @access protected * @param string * @param string * @return string @@ -1671,7 +1621,6 @@ class CI_Email { /** * SMTP Authenticate * - * @access protected * @return bool */ protected function _smtp_authenticate() @@ -1725,7 +1674,6 @@ class CI_Email { /** * Send SMTP data * - * @access protected * @return bool */ protected function _send_data($data) @@ -1744,7 +1692,6 @@ class CI_Email { /** * Get SMTP data * - * @access protected * @return string */ protected function _get_smtp_data() @@ -1769,7 +1716,6 @@ class CI_Email { /** * Get Hostname * - * @access protected * @return string */ protected function _get_hostname() @@ -1782,7 +1728,6 @@ class CI_Email { /** * Get IP * - * @access protected * @return string */ protected function _get_ip() @@ -1824,7 +1769,6 @@ class CI_Email { /** * Get Debug Message * - * @access public * @return string */ public function print_debugger() @@ -1848,9 +1792,8 @@ class CI_Email { /** * Set Message * - * @access protected * @param string - * @return string + * @return void */ protected function _set_error_message($msg, $val = '') { @@ -1872,7 +1815,6 @@ class CI_Email { /** * Mime Types * - * @access protected * @param string * @return string */ @@ -1971,7 +1913,6 @@ class CI_Email { } } -// END CI_Email class /* End of file Email.php */ /* Location: ./system/libraries/Email.php */ -- cgit v1.2.3-24-g4f1b From 76f15c9bb3004e6da99dd273c34ef3b92a23c17f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 13:05:07 +0200 Subject: Switch ANDs to &&, || to OR in the Email class --- system/libraries/Email.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 898effeb6..f1b18ab4f 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -101,7 +101,7 @@ class CI_Email { } else { - $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE; + $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); $this->_safe_mode = (bool) @ini_get("safe_mode"); } @@ -136,7 +136,7 @@ class CI_Email { } $this->clear(); - $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE; + $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); $this->_safe_mode = (bool) @ini_get("safe_mode"); return $this; @@ -553,7 +553,7 @@ class CI_Email { */ public function set_crlf($crlf = "\n") { - $this->crlf = ($crlf !== "\n" AND $crlf !== "\r\n" AND $crlf !== "\r") ? "\n" : $crlf; + $this->crlf = ($crlf !== "\n" && $crlf !== "\r\n" && $crlf !== "\r") ? "\n" : $crlf; return $this; } @@ -932,7 +932,7 @@ class CI_Email { */ protected function _build_message() { - if ($this->wordwrap === TRUE AND $this->mailtype !== 'html') + if ($this->wordwrap === TRUE && $this->mailtype !== 'html') { $this->_body = $this->word_wrap($this->_body); } @@ -1255,9 +1255,9 @@ class CI_Email { $this->reply_to($this->_headers['From']); } - if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND - ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND - ( ! isset($this->_headers['Cc']))) + if ( ! isset($this->_recipients) && ! isset($this->_headers['To']) + && ! isset($this->_bcc_array) && ! isset($this->_headers['Bcc']) + && ! isset($this->_headers['Cc'])) { $this->_set_error_message('lang:email_no_recipients'); return FALSE; @@ -1265,13 +1265,12 @@ class CI_Email { $this->_build_headers(); - if ($this->bcc_batch_mode AND count($this->_bcc_array) > $this->bcc_batch_size) + if ($this->bcc_batch_mode && count($this->_bcc_array) > $this->bcc_batch_size) { return $this->batch_bcc_send(); } $this->_build_message(); - return $this->_spool_email(); } @@ -1630,7 +1629,7 @@ class CI_Email { return TRUE; } - if ($this->smtp_user == "" AND $this->smtp_pass == "") + if ($this->smtp_user == '' && $this->smtp_pass == '') { $this->_set_error_message('lang:email_no_smtp_unpw'); return FALSE; @@ -1737,13 +1736,13 @@ class CI_Email { return $this->_IP; } - $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE; - $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE; + $cip = ( ! empty($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : FALSE; + $rip = ( ! empty($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : FALSE; if ($cip) $this->_IP = $cip; elseif ($rip) $this->_IP = $rip; else { - $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE; + $fip = ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE; if ($fip) { $this->_IP = $fip; @@ -1800,7 +1799,7 @@ class CI_Email { $CI =& get_instance(); $CI->lang->load('email'); - if (substr($msg, 0, 5) !== 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5)))) + if (substr($msg, 0, 5) !== 'lang:' OR FALSE === ($line = $CI->lang->line(substr($msg, 5)))) { $this->_debug_msg[] = str_replace('%s', $val, $msg)."
"; } -- cgit v1.2.3-24-g4f1b From 59c5b537cb5880930f9a8d518659c75cd66f41b0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 14:09:51 +0200 Subject: Some other minor improvements to the Email library --- system/libraries/Email.php | 148 ++++++++++++++++++++------------------------- 1 file changed, 67 insertions(+), 81 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f1b18ab4f..c8a5b41af 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -38,29 +38,29 @@ */ class CI_Email { - public $useragent = "CodeIgniter"; - public $mailpath = "/usr/sbin/sendmail"; // Sendmail path - public $protocol = "mail"; // mail/sendmail/smtp - public $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net - public $smtp_user = ""; // SMTP Username - public $smtp_pass = ""; // SMTP Password - public $smtp_port = "25"; // SMTP Port - public $smtp_timeout = 5; // SMTP Timeout in seconds - public $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl. - public $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off - public $wrapchars = "76"; // Number of characters to wrap at. - public $mailtype = "text"; // text/html Defines email formatting - public $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii - public $multipart = "mixed"; // "mixed" (in the body) or "related" (separate) - public $alt_message = ''; // Alternative message for HTML emails - public $validate = FALSE; // TRUE/FALSE. Enables email validation - public $priority = "3"; // Default priority (1 - 5) - public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) - public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, + public $useragent = 'CodeIgniter'; + public $mailpath = '/usr/sbin/sendmail'; // Sendmail path + public $protocol = 'mail'; // mail/sendmail/smtp + public $smtp_host = ''; // SMTP Server. Example: mail.earthlink.net + public $smtp_user = ''; // SMTP Username + public $smtp_pass = ''; // SMTP Password + public $smtp_port = 25; // SMTP Port + public $smtp_timeout = 5; // SMTP Timeout in seconds + public $smtp_crypto = ''; // SMTP Encryption. Can be null, tls or ssl. + public $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off + public $wrapchars = 76; // Number of characters to wrap at. + public $mailtype = 'text'; // text/html Defines email formatting + public $charset = 'utf-8'; // Default char set: iso-8859-1 or us-ascii + public $multipart = 'mixed'; // "mixed" (in the body) or "related" (separate) + public $alt_message = ''; // Alternative message for HTML emails + public $validate = FALSE; // TRUE/FALSE. Enables email validation + public $priority = 3; // Default priority (1 - 5) + public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) + public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. - public $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature + public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch protected $_safe_mode = FALSE; @@ -102,10 +102,10 @@ class CI_Email { else { $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); - $this->_safe_mode = (bool) @ini_get("safe_mode"); + $this->_safe_mode = (bool) @ini_get('safe_mode'); } - log_message('debug', "Email Class Initialized"); + log_message('debug', 'Email Class Initialized'); } // -------------------------------------------------------------------- @@ -137,7 +137,7 @@ class CI_Email { $this->clear(); $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); - $this->_safe_mode = (bool) @ini_get("safe_mode"); + $this->_safe_mode = (bool) @ini_get('safe_mode'); return $this; } @@ -152,11 +152,11 @@ class CI_Email { */ public function clear($clear_attachments = FALSE) { - $this->_subject = ""; - $this->_body = ""; - $this->_finalbody = ""; - $this->_header_str = ""; - $this->_replyto_flag = FALSE; + $this->_subject = ''; + $this->_body = ''; + $this->_finalbody = ''; + $this->_header_str = ''; + $this->_replyto_flag = FALSE; $this->_recipients = array(); $this->_cc_array = array(); $this->_bcc_array = array(); @@ -187,7 +187,7 @@ class CI_Email { */ public function from($from, $name = '') { - if (preg_match( '/\<(.*)\>/', $from, $match)) + if (preg_match('/\<(.*)\>/', $from, $match)) { $from = $match[1]; } @@ -229,7 +229,7 @@ class CI_Email { */ public function reply_to($replyto, $name = '') { - if (preg_match( '/\<(.*)\>/', $replyto, $match)) + if (preg_match('/\<(.*)\>/', $replyto, $match)) { $replyto = $match[1]; } @@ -275,17 +275,17 @@ class CI_Email { if ($this->_get_protocol() !== 'mail') { - $this->_set_header('To', implode(", ", $to)); + $this->_set_header('To', implode(', ', $to)); } switch ($this->_get_protocol()) { - case 'smtp' : + case 'smtp': $this->_recipients = $to; break; - case 'sendmail' : - case 'mail' : - $this->_recipients = implode(", ", $to); + case 'sendmail': + case 'mail': + $this->_recipients = implode(', ', $to); break; } @@ -310,7 +310,7 @@ class CI_Email { $this->validate_email($cc); } - $this->_set_header('Cc', implode(", ", $cc)); + $this->_set_header('Cc', implode(', ', $cc)); if ($this->_get_protocol() === 'smtp') { @@ -351,7 +351,7 @@ class CI_Email { } else { - $this->_set_header('Bcc', implode(", ", $bcc)); + $this->_set_header('Bcc', implode(', ', $bcc)); } return $this; @@ -382,7 +382,7 @@ class CI_Email { */ public function message($body) { - $this->_body = rtrim(str_replace("\r", "", $body)); + $this->_body = rtrim(str_replace("\r", '', $body)); /* strip slashes only if magic quotes is ON if we do it with magic quotes OFF, it strips real, user-inputted chars. @@ -446,8 +446,7 @@ class CI_Email { } else { - $email = trim($email); - settype($email, "array"); + $email = (array) trim($email); } } return $email; @@ -505,7 +504,7 @@ class CI_Email { */ public function set_protocol($protocol = 'mail') { - $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol); + $this->protocol = in_array($protocol, $this->_protocols, TRUE) ? strtolower($protocol) : 'mail'; return $this; } @@ -519,13 +518,7 @@ class CI_Email { */ public function set_priority($n = 3) { - if ( ! is_numeric($n) OR $n < 1 OR $n > 5) - { - $this->priority = 3; - return; - } - - $this->priority = (int) $n; + $this->priority = preg_match('/^[1-5]$/', $n) ? (int) $n : 3; return $this; } @@ -566,8 +559,8 @@ class CI_Email { */ protected function _set_boundaries() { - $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative - $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary + $this->_alt_boundary = 'B_ALT_'.uniqid(''); // multipart/alternative + $this->_atc_boundary = 'B_ATC_'.uniqid(''); // attachment boundary } // -------------------------------------------------------------------- @@ -580,8 +573,7 @@ class CI_Email { protected function _get_message_id() { $from = str_replace(array('>', '<'), '', $this->_headers['Return-Path']); - - return "<".uniqid('').strstr($from, '@').">"; + return '<'.uniqid('').strstr($from, '@').'>'; } // -------------------------------------------------------------------- @@ -590,12 +582,12 @@ class CI_Email { * Get Mail Protocol * * @param bool - * @return string + * @return mixed */ protected function _get_protocol($return = TRUE) { $this->protocol = strtolower($this->protocol); - $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol; + in_array($this->protocol, $this->_protocols, TRUE) OR $this->protocol = 'mail'; if ($return == TRUE) { @@ -613,7 +605,7 @@ class CI_Email { */ protected function _get_encoding($return = TRUE) { - $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding; + in_array($this->_encoding, $this->_bit_depths) OR $this->_encoding = '8bit'; foreach ($this->_base_charsets as $charset) { @@ -665,12 +657,12 @@ class CI_Email { */ protected function _set_date() { - $timezone = date("Z"); + $timezone = date('Z'); $operator = (strncmp($timezone, '-', 1) === 0) ? '-' : '+'; $timezone = abs($timezone); $timezone = floor($timezone/3600) * 100 + ($timezone % 3600) / 60; - return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone); + return sprintf('%s %s%04d', date('D, j M Y H:i:s'), $operator, $timezone); } // -------------------------------------------------------------------- @@ -682,7 +674,7 @@ class CI_Email { */ protected function _get_mime_message() { - return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format."; + return 'This is a multi-part message in MIME format.'.$this->newline.'Your email application may not support this format.'; } // -------------------------------------------------------------------- @@ -723,7 +715,7 @@ class CI_Email { */ public function valid_email($address) { - return (bool) preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address); + return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $address); } // -------------------------------------------------------------------- @@ -745,7 +737,7 @@ class CI_Email { foreach ($email as $addy) { - $clean_email[] = (preg_match( '/\<(.*)\>/', $addy, $match)) ? $match[1] : $addy; + $clean_email[] = preg_match('/\<(.*)\>/', $addy, $match) ? $match[1] : $addy; } return $clean_email; @@ -765,7 +757,7 @@ class CI_Email { */ protected function _get_alt_message() { - if ($this->alt_message != "") + if ($this->alt_message != '') { return $this->word_wrap($this->alt_message, '76'); } @@ -1165,9 +1157,7 @@ class CI_Email { } // get rid of extra CRLF tacked onto the end - $output = substr($output, 0, strlen($this->crlf) * -1); - - return $output; + return substr($output, 0, strlen($this->crlf) * -1); } // -------------------------------------------------------------------- @@ -1236,9 +1226,7 @@ class CI_Email { // wrap each line with the shebang, charset, and transfer encoding // the preceding space on successive lines is required for header "folding" - $str = trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str)); - - return $str; + return trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str)); } // -------------------------------------------------------------------- @@ -1283,24 +1271,22 @@ class CI_Email { */ public function batch_bcc_send() { - $float = $this->bcc_batch_size -1; - - $set = ""; - + $float = $this->bcc_batch_size - 1; + $set = ''; $chunk = array(); for ($i = 0, $c = count($this->_bcc_array); $i < $c; $i++) { if (isset($this->_bcc_array[$i])) { - $set .= ", ".$this->_bcc_array[$i]; + $set .= ', '.$this->_bcc_array[$i]; } if ($i == $float) { $chunk[] = substr($set, 1); $float += $this->bcc_batch_size; - $set = ""; + $set = ''; } if ($i === $c-1) @@ -1317,7 +1303,7 @@ class CI_Email { if ($this->protocol !== 'smtp') { - $this->_set_header('Bcc', implode(", ", $bcc)); + $this->_set_header('Bcc', implode(', ', $bcc)); } else { @@ -1719,7 +1705,7 @@ class CI_Email { */ protected function _get_hostname() { - return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'; + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'; } // -------------------------------------------------------------------- @@ -1755,7 +1741,7 @@ class CI_Email { $this->_IP = end($x); } - if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP)) + if ( ! preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $this->_IP)) { $this->_IP = '0.0.0.0'; } @@ -1782,8 +1768,7 @@ class CI_Email { } } - $msg .= "
".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'
'; - return $msg; + return $msg.'
'.$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'
'; } // -------------------------------------------------------------------- @@ -1817,9 +1802,10 @@ class CI_Email { * @param string * @return string */ - protected function _mime_types($ext = "") + protected function _mime_types($ext = '') { - $mimes = array( 'hqx' => 'application/mac-binhex40', + $mimes = array( + 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', @@ -1908,7 +1894,7 @@ class CI_Email { 'eml' => 'message/rfc822' ); - return ( ! isset($mimes[strtolower($ext)])) ? "application/x-unknown-content-type" : $mimes[strtolower($ext)]; + return isset($mimes[strtolower($ext)]) ? $mimes[strtolower($ext)] : 'application/x-unknown-content-type'; } } -- cgit v1.2.3-24-g4f1b From c2905f5884a7d9cd9ae1f70cdc615a5d214652dd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 14:39:26 +0200 Subject: Fix an Oracle escape_str() bug (#68, #414) --- system/database/drivers/oci8/oci8_driver.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index c6621901b..057095c23 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -398,10 +398,9 @@ class CI_DB_oci8_driver extends CI_DB { /** * Escape String * - * @access public - * @param string + * @param string * @param bool whether or not the string will be used in a LIKE condition - * @return string + * @return string */ public function escape_str($str, $like = FALSE) { @@ -415,15 +414,14 @@ class CI_DB_oci8_driver extends CI_DB { return $str; } - $str = remove_invisible_characters($str); - $str = str_replace("'", "''", $str); + $str = str_replace("'", "''", remove_invisible_characters($str)); // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), - $str); + return str_replace(array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), + $str); } return $str; -- cgit v1.2.3-24-g4f1b From 41e46a97a43b0d5080bb9ace1b9326266955ef21 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 14:58:17 +0200 Subject: Fix issue #81 (ODBC list_fields(), field_data()) --- system/database/drivers/odbc/odbc_result.php | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index ba660856e..bfd6949eb 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -54,10 +54,9 @@ class CI_DB_odbc_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public - * @return integer + * @return int */ - function num_fields() + public function num_fields() { return @odbc_num_fields($this->result_id); } @@ -69,15 +68,19 @@ class CI_DB_odbc_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); - for ($i = 0; $i < $this->num_fields(); $i++) + $num_fields = $this->num_fields(); + + if ($num_fields > 0) { - $field_names[] = odbc_field_name($this->result_id, $i); + for ($i = 1; $i <= $num_fields; $i++) + { + $field_names[] = odbc_field_name($this->result_id, $i); + } } return $field_names; @@ -90,22 +93,19 @@ class CI_DB_odbc_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); - for ($i = 0; $i < $this->num_fields(); $i++) + for ($i = 0, $odbc_index = 1, $c = $this->num_fields(); $i < $c; $i++, $odbc_index++) { - $F = new stdClass(); - $F->name = odbc_field_name($this->result_id, $i); - $F->type = odbc_field_type($this->result_id, $i); - $F->max_length = odbc_field_len($this->result_id, $i); - $F->primary_key = 0; - $F->default = ''; - - $retval[] = $F; + $retval[$i] = new stdClass(); + $retval[$i]->name = odbc_field_name($this->result_id, $odbc_index); + $retval[$i]->type = odbc_field_type($this->result_id, $odbc_index); + $retval[$i]->max_length = odbc_field_len($this->result_id, $odbc_index); + $retval[$i]->primary_key = 0; + $retval[$i]->default = ''; } return $retval; @@ -237,4 +237,4 @@ class CI_DB_odbc_result extends CI_DB_result { /* End of file odbc_result.php */ -/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file +/* Location: ./system/database/drivers/odbc/odbc_result.php */ -- cgit v1.2.3-24-g4f1b From ef795ac23320c4636152af03c8600f2115f1e6e3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 15:15:31 +0200 Subject: Fix issue #129 (ODBC num_rows() returning -1 in some cases) --- system/database/drivers/odbc/odbc_result.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index bfd6949eb..572e110ca 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -38,15 +38,27 @@ */ class CI_DB_odbc_result extends CI_DB_result { + public $num_rows; + /** * Number of rows in the result set * - * @access public - * @return integer + * @return int */ - function num_rows() + public function num_rows() { - return @odbc_num_rows($this->result_id); + if (is_int($this->num_rows)) + { + return $this->num_rows; + } + + // Work-around for ODBC subdrivers that don't support num_rows() + if (($this->num_rows = @odbc_num_rows($this->result_id)) === -1) + { + $this->num_rows = count($this->result_array()); + } + + return $this->num_rows; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 6ca407e22104d9ba3ef729c840b7dee903df1531 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 15:33:21 +0200 Subject: Fix issue #153 (E_NOTICE generated by getimagesize()) --- system/libraries/Upload.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 0b853233d..ac29c1bdd 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1,4 +1,4 @@ -allowed_types == '*') + if ($this->allowed_types === '*') { return TRUE; } - if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types)) + if ( ! is_array($this->allowed_types) OR count($this->allowed_types) === 0) { $this->set_error('upload_no_file_types'); return FALSE; @@ -618,12 +619,9 @@ class CI_Upload { // Images get some additional checks $image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe'); - if (in_array($ext, $image_types)) + if (in_array($ext, $image_types) && @getimagesize($this->file_temp) === FALSE) { - if (getimagesize($this->file_temp) === FALSE) - { - return FALSE; - } + return FALSE; } if ($ignore_mime === TRUE) @@ -640,7 +638,7 @@ class CI_Upload { return TRUE; } } - elseif ($mime == $this->file_type) + elseif ($mime === $this->file_type) { return TRUE; } -- cgit v1.2.3-24-g4f1b From 850f601edef5de5680510c900c3e613bc346fe1b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 15:58:25 +0200 Subject: Fix issue #611 (SQLSRV _error_message() and _error_number() warnings) --- system/database/drivers/sqlsrv/sqlsrv_driver.php | 35 ++++++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 9c50209ec..e4fd90240 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -424,13 +424,18 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * The error message string * - * @access private * @return string */ - function _error_message() + protected function _error_message() { - $error = array_shift(sqlsrv_errors()); - return !empty($error['message']) ? $error['message'] : null; + $error = sqlsrv_errors(); + if ( ! is_array($error)) + { + return ''; + } + + $error = array_shift($error); + return isset($error['message']) ? $error['message'] : ''; } // -------------------------------------------------------------------- @@ -438,13 +443,25 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * The error message number * - * @access private - * @return integer + * @return string */ - function _error_number() + protected function _error_number() { - $error = array_shift(sqlsrv_errors()); - return isset($error['SQLSTATE']) ? $error['SQLSTATE'] : null; + $error = sqlsrv_errors(); + if ( ! is_array($error)) + { + return ''; + } + elseif (isset($error['SQLSTATE'])) + { + return isset($error['code']) ? $error['SQLSTATE'].'/'.$error['code'] : $error['SQLSTATE']; + } + elseif (isset($error['code'])) + { + return $error['code']; + } + + return ''; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 67f71a415c4bd7a206fcfc1a6007d74af4590883 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 16:18:42 +0200 Subject: Fix issue #1036 (is_write_type() returned FALSE for RENAME, OPTIMIZE queries) --- system/database/DB_driver.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 6352c731e..8ab5415ea 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -645,17 +645,12 @@ class CI_DB_driver { /** * Determines if a query is a "write" type. * - * @access public * @param string An SQL query string - * @return boolean + * @return bool */ - function is_write_type($sql) + public function is_write_type($sql) { - if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql)) - { - return FALSE; - } - return TRUE; + return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|OPTIMIZE)\s+/i', $sql); } // -------------------------------------------------------------------- @@ -1443,4 +1438,4 @@ class CI_DB_driver { } /* End of file DB_driver.php */ -/* Location: ./system/database/DB_driver.php */ \ No newline at end of file +/* Location: ./system/database/DB_driver.php */ -- cgit v1.2.3-24-g4f1b From ed7408282e9fded97ade222f98b43623a0f17d22 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 16:37:08 +0200 Subject: Fix PDO's _version() method where it used to return client version instead of the server one --- system/database/drivers/pdo/pdo_driver.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index de2b0abeb..44e93a042 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -306,12 +306,11 @@ class CI_DB_pdo_driver extends CI_DB { /** * Version number query string * - * @access public * @return string */ - function _version() + protected function _version() { - return $this->conn_id->getAttribute(PDO::ATTR_CLIENT_VERSION); + return $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION); } // -------------------------------------------------------------------- @@ -950,4 +949,4 @@ class CI_DB_pdo_driver extends CI_DB { } /* End of file pdo_driver.php */ -/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/pdo/pdo_driver.php */ -- cgit v1.2.3-24-g4f1b From a39d699f90feb359ab994b3d77d71006060afecc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 19:11:39 +0200 Subject: Fix a bug in PDO's insert_id() (PostgreSQL-specific) --- system/database/drivers/pdo/pdo_driver.php | 32 +++++++++--------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 44e93a042..dd803aba1 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -509,33 +509,19 @@ class CI_DB_pdo_driver extends CI_DB { /** * Insert ID - * - * @access public - * @return integer + * + * @return int */ - function insert_id($name=NULL) + public function insert_id($name = NULL) { - if ($this->pdodriver == 'pgsql') - { - //Convenience method for postgres insertid - $v = $this->_version(); - - $table = func_num_args() > 0 ? func_get_arg(0) : NULL; - - if ($table == NULL && $v >= '8.1') - { - $sql='SELECT LASTVAL() as ins_id'; - } - - $query = $this->query($sql); - $row = $query->row(); - - return $row->ins_id; - } - else + if ($this->pdodriver === 'pgsql' && $name === NULL && $this->_version() >= '8.1') { - return $this->conn_id->lastInsertId($name); + $query = $this->query('SELECT LASTVAL() AS ins_id'); + $query = $query->row(); + return $query->ins_id; } + + return $this->conn_id->lastInsertId($name); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From ea3eec9f670ea861a65a3e251d8c518ff47e2506 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 19:16:23 +0200 Subject: Fixed a bug in CUBRID's affected_rows() --- system/database/drivers/cubrid/cubrid_driver.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index cde719eae..8738a2e87 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -362,12 +362,11 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ - function affected_rows() + public function affected_rows() { - return @cubrid_affected_rows($this->conn_id); + return @cubrid_affected_rows(); } // -------------------------------------------------------------------- @@ -801,4 +800,4 @@ class CI_DB_cubrid_driver extends CI_DB { /* End of file cubrid_driver.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ -- cgit v1.2.3-24-g4f1b From 927e950cb9e01d02415e13a8fb13eb95ce4a31c6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 19:50:26 +0200 Subject: Remove SQLite3 db_set_charset() - no longer needed --- system/database/drivers/sqlite3/sqlite3_driver.php | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index eb9a8f526..1f2d8f0a0 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -119,21 +119,6 @@ class CI_DB_sqlite3_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @param string - * @param string - * @return bool - */ - public function db_set_charset($charset, $collation) - { - // Not (natively) supported - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * -- cgit v1.2.3-24-g4f1b From 601f8b209d93fe70786776d9170eed5e23201e58 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 20:11:15 +0200 Subject: Fix issue #413 (Oracle _error_message(), _error_number()) --- system/database/drivers/oci8/oci8_driver.php | 38 ++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index d9acaaea6..6da6dc724 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -529,13 +529,11 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message string * - * @access protected - * @return string + * @return string */ protected function _error_message() { - // If the error was during connection, no conn_id should be passed - $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); + $error = $this->_oci8_error_data(); return $error['message']; } @@ -544,18 +542,42 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message number * - * @access protected - * @return integer + * @return string */ protected function _error_number() { - // Same as _error_message() - $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); + $error = $this->_oci8_error_data(); return $error['code']; } // -------------------------------------------------------------------- + /** + * OCI8-specific method to get errors. + * Used by _error_message() and _error_code(). + * + * @return array + */ + protected function _oci8_error_data() + { + if (is_resource($this->curs_id)) + { + return oci_error($this->curs_id); + } + elseif (is_resource($this->stmt_id)) + { + return oci_error($this->stmt_id); + } + elseif (is_resource($this->conn_id)) + { + return oci_error($this->conn_id); + } + + return oci_error(); + } + + // -------------------------------------------------------------------- + /** * Escape the SQL Identifiers * -- cgit v1.2.3-24-g4f1b From 8edf87dbb0dcbe61e8cbaa6229c70a46bee6dbd4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 20:20:03 +0200 Subject: Remove a PHP_VERSION < 5 check (no longer needed) --- system/helpers/text_helper.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'system') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 842a31d75..6e9ea570f 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -300,9 +300,9 @@ if ( ! function_exists('highlight_code')) // Replace any existing PHP tags to temporary markers so they don't accidentally // break the string out of PHP, and thus, thwart the highlighting. - $str = str_replace(array('', '<%', '%>', '\\', ''), - array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str); + array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), + $str); // The highlight_string function requires that the text be surrounded // by PHP tags, which we will remove later @@ -311,25 +311,15 @@ if ( ! function_exists('highlight_code')) // All the magic happens here, baby! $str = highlight_string($str, TRUE); - // Prior to PHP 5, the highligh function used icky tags - // so we'll replace them with tags. - - if (abs(PHP_VERSION) < 5) - { - $str = str_replace(array(''), array(''), $str); - $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str); - } - // Remove our artificially added PHP, and the syntax highlighting that came with it $str = preg_replace('/<\?php( | )/i', '', $str); $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str); $str = preg_replace('/<\/span>/i', '', $str); // Replace our markers back to PHP tags. - $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), - array('<?', '?>', '<%', '%>', '\\', '</script>'), $str); - - return $str; + return str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), + array('<?', '?>', '<%', '%>', '\\', '</script>'), + $str); } } @@ -544,4 +534,4 @@ if ( ! function_exists('ellipsize')) } /* End of file text_helper.php */ -/* Location: ./system/helpers/text_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/text_helper.php */ -- cgit v1.2.3-24-g4f1b From ef7474c6ca9887283c964e17c450ca09559643c4 Mon Sep 17 00:00:00 2001 From: Ryan Dial Date: Thu, 1 Mar 2012 16:11:36 -0500 Subject: compile binds before caching the query, otherwise the cached query will never match the unbound query. updated changlog to mention bug fix. --- system/database/DB_driver.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 4dfb584f2..6161f149b 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -265,6 +265,12 @@ class CI_DB_driver { $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql); } + // Compile binds if needed + if ($binds !== FALSE) + { + $sql = $this->compile_binds($sql, $binds); + } + // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists @@ -280,12 +286,6 @@ class CI_DB_driver { } } - // Compile binds if needed - if ($binds !== FALSE) - { - $sql = $this->compile_binds($sql, $binds); - } - // Save the query for debugging if ($this->save_queries == TRUE) { -- cgit v1.2.3-24-g4f1b From 963386ba6072d240840b58d6dbe54287edcb04ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 01:52:01 +0200 Subject: Fix issue #803 (Profiler library didn't handle objects properly) --- system/libraries/Profiler.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 89c616543..04216be5d 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -270,7 +270,7 @@ class CI_Profiler { } $output .= "$_GET[".$key."]   " - . (is_array($val) ? "
" . htmlspecialchars(stripslashes(print_r($val, true))) . "
" : htmlspecialchars(stripslashes($val))) + . ((is_array($val) OR is_object($val)) ? "
" . htmlspecialchars(stripslashes(print_r($val, true))) . "
" : htmlspecialchars(stripslashes($val))) . "\n"; } @@ -311,7 +311,7 @@ class CI_Profiler { } $output .= "$_POST[".$key."]   "; - if (is_array($val)) + if (is_array($val) OR is_object($val)) { $output .= "
" . htmlspecialchars(stripslashes(print_r($val, TRUE))) . "
"; } @@ -426,9 +426,9 @@ class CI_Profiler { . '  '.$this->CI->lang->line('profiler_config').'  ('.$this->CI->lang->line('profiler_section_show').')' . "\n\n\n\n"; - foreach ($this->CI->config->config as $config=>$val) + foreach ($this->CI->config->config as $config => $val) { - if (is_array($val)) + if (is_array($val) OR is_object($val)) { $val = print_r($val, TRUE); } @@ -459,7 +459,7 @@ class CI_Profiler { foreach ($this->CI->session->all_userdata() as $key => $val) { - if (is_array($val) || is_object($val)) + if (is_array($val) OR is_object($val)) { $val = print_r($val, TRUE); } @@ -501,7 +501,5 @@ class CI_Profiler { } } -// END CI_Profiler class - /* End of file Profiler.php */ /* Location: ./system/libraries/Profiler.php */ -- cgit v1.2.3-24-g4f1b From 676a0dd74409e7e838b94484ef9ba066dcf6db91 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Fri, 2 Mar 2012 10:10:34 +0100 Subject: updated error_array #565 --- system/libraries/Form_validation.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 2ee734ae6..5069a44c1 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -234,6 +234,20 @@ class CI_Form_validation { // -------------------------------------------------------------------- + /** + * Get Array of Error Messages + * + * Returns the error messages as an array + * + * @return array + */ + public function error_array() + { + return $this->_error_array; + } + + // -------------------------------------------------------------------- + /** * Error String * -- cgit v1.2.3-24-g4f1b From effd0133b3fa805e21ec934196e8e7d75608ba00 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 12:34:54 +0200 Subject: Fix issue #1101 (MySQL/MySQLi result field_data()) --- system/database/drivers/mysql/mysql_result.php | 18 +++++++----------- system/database/drivers/mysqli/mysqli_result.php | 19 ++++++++----------- 2 files changed, 15 insertions(+), 22 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index 8f04a936d..5a65d9c72 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -90,18 +90,14 @@ class CI_DB_mysql_result extends CI_DB_result { public function field_data() { $retval = array(); - while ($field = mysql_fetch_object($this->result_id)) + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) { - preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches); - - $F = new stdClass(); - $F->name = $field->Field; - $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL; - $F->default = $field->Default; - $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL; - $F->primary_key = (int) ($field->Key === 'PRI'); - - $retval[] = $F; + $retval[$i] = new stdClass(); + $retval[$i]->name = mysql_field_name($this->result_id, $i); + $retval[$i]->type = mysql_field_type($this->result_id, $i); + $retval[$i]->max_length = mysql_field_len($this->result_id, $i); + $retval[$i]->primary_key = (strpos(mysql_field_flags($this->result_id, $i), 'primary_key') === FALSE) ? 0 : 1; + $retval[$i]->default = ''; } return $retval; diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index 0a50cccac..8b909cc56 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -90,18 +90,15 @@ class CI_DB_mysqli_result extends CI_DB_result { public function field_data() { $retval = array(); - while ($field = mysqli_fetch_object($this->result_id)) + $field_data = mysqli_fetch_fields($this->result_id); + for ($i = 0, $c = count($field_data); $i < $c; $i++) { - preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches); - - $F = new stdClass(); - $F->name = $field->Field; - $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL; - $F->default = $field->Default; - $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL; - $F->primary_key = (int) ($field->Key === 'PRI'); - - $retval[] = $F; + $retval[$i] = new stdClass(); + $retval[$i]->name = $field_data[$i]->name; + $retval[$i]->type = $field_data[$i]->type; + $retval[$i]->max_length = $field_data[$i]->max_length; + $retval[$i]->primary_key = (int) ($field_data[$i]->flags & 2); + $retval[$i]->default = ''; } return $retval; -- cgit v1.2.3-24-g4f1b From 8f22057724dd8fe2b9d41ba98bfc4da282572c5e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 13:05:45 +0200 Subject: Fix a bug in Oracle's DB forge _create_table() method (AUTO_INCREMENT is not supported) --- system/database/drivers/oci8/oci8_forge.php | 64 ++++++++--------------------- 1 file changed, 17 insertions(+), 47 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index b4a24cdca..0aa119907 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -67,15 +67,14 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @param bool should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -84,54 +83,27 @@ class CI_DB_oci8_forge extends CI_DB_forge { $sql .= 'IF NOT EXISTS '; } - $sql .= $this->db->_escape_identifiers($table)." ("; + $sql .= $this->db->_escape_identifiers($table).' ('; $current_field_count = 0; - foreach ($fields as $field=>$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually // entered the field information, so we'll simply add it to the list if (is_numeric($field)) { - $sql .= "\n\t$attributes"; + $sql .= "\n\t".$attributes; } else { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); - - $sql .= ' '.$attributes['TYPE']; - - if (array_key_exists('CONSTRAINT', $attributes)) - { - $sql .= '('.$attributes['CONSTRAINT'].')'; - } - - if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) - { - $sql .= ' UNSIGNED'; - } - - if (array_key_exists('DEFAULT', $attributes)) - { - $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; - } - - if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) - { - $sql .= ' NULL'; - } - else - { - $sql .= ' NOT NULL'; - } - - if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) - { - $sql .= ' AUTO_INCREMENT'; - } + $sql .= "\n\t".$this->db->protect_identifiers($field).' '.$attributes['TYPE'] + .((isset($attributes['UNSINGED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') + .(isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') + .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? '' : ' NOT NULL') + .(isset($attributes['CONSTRAINT']) ? ' CONSTRAINT '.$attributes['CONSTRAINT'] : ''); } // don't add a comma on the end of the last field @@ -143,8 +115,8 @@ class CI_DB_oci8_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); - $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; + $primary_keys = $this->db->protect_identifiers($primary_keys); + $sql .= ",\n\tCONSTRAINT ".$table.' PRIMARY KEY ('.implode(', ', $primary_keys).')'; } if (is_array($keys) && count($keys) > 0) @@ -153,20 +125,18 @@ class CI_DB_oci8_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } - $sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")"; + $sql .= ",\n\tUNIQUE COLUMNS (".implode(', ', $key).")"; } } - $sql .= "\n)"; - - return $sql; + return $sql."\n)"; } // -------------------------------------------------------------------- @@ -257,4 +227,4 @@ class CI_DB_oci8_forge extends CI_DB_forge { } /* End of file oci8_forge.php */ -/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/oci8/oci8_forge.php */ -- cgit v1.2.3-24-g4f1b From a92c7cdeddd9f1b46a6c8f254b2949ad047bbc21 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 13:51:22 +0200 Subject: Change SQLite3 _execute to use is_write_type() --- system/database/drivers/sqlite3/sqlite3_driver.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index 1f2d8f0a0..2af973875 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -139,14 +139,12 @@ class CI_DB_sqlite3_driver extends CI_DB { */ protected function _execute($sql) { - if ( ! preg_match('/^(SELECT|EXPLAIN).+$/i', ltrim($sql))) - { - return $this->conn_id->exec($sql); - } - // TODO: Implement use of SQLite3::querySingle(), if needed // TODO: Use $this->_prep_query(), if needed - return $this->conn_id->query($sql); + + return $this->is_write_type($sql) + ? $this->conn_id->exec($sql) + : $this->conn_id->query($sql); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From bcb3bbb97c8c046f80009a2bd8dffb96795ed239 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 13:56:15 +0200 Subject: Added method visibility declarations to SQLite DB utility class --- system/database/drivers/sqlite/sqlite_utility.php | 41 +++++++++-------------- 1 file changed, 15 insertions(+), 26 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index f00687e38..8fefcd9e2 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -1,13 +1,13 @@ -db_debug) - { - return $this->db->display_error('db_unsuported_feature'); - } - return array(); + return ($this->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } // -------------------------------------------------------------------- @@ -61,14 +54,12 @@ class CI_DB_sqlite_utility extends CI_DB_utility { /** * Optimize table query * - * Is optimization even supported in SQLite? - * - * @access private * @param string the table name - * @return object + * @return bool */ - function _optimize_table($table) + public function _optimize_table($table) { + // Not supported return FALSE; } @@ -77,14 +68,12 @@ class CI_DB_sqlite_utility extends CI_DB_utility { /** * Repair table query * - * Are table repairs even supported in SQLite? - * - * @access private * @param string the table name - * @return object + * @return bool */ - function _repair_table($table) + public function _repair_table($table) { + // Not supported return FALSE; } @@ -93,16 +82,16 @@ class CI_DB_sqlite_utility extends CI_DB_utility { /** * SQLite Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); } + } /* End of file sqlite_utility.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file +/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ -- cgit v1.2.3-24-g4f1b From 4be5de1d11eefd9f0b7cf0589a2942f067cefe35 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 15:45:41 +0200 Subject: Replaced DB methods _error_message() and _error_number() with error() (issue #1097) --- system/database/DB_driver.php | 22 +++++----- system/database/drivers/cubrid/cubrid_driver.php | 25 +++--------- system/database/drivers/mssql/mssql_driver.php | 26 ++++-------- system/database/drivers/mysql/mysql_driver.php | 21 +++------- system/database/drivers/mysqli/mysqli_driver.php | 21 +++------- system/database/drivers/oci8/oci8_driver.php | 35 ++++------------ system/database/drivers/odbc/odbc_driver.php | 23 +++-------- system/database/drivers/pdo/pdo_driver.php | 35 ++++++++-------- system/database/drivers/postgre/postgre_driver.php | 23 +++-------- system/database/drivers/sqlite/sqlite_driver.php | 25 ++++-------- system/database/drivers/sqlsrv/sqlsrv_driver.php | 47 +++++++++------------- 11 files changed, 101 insertions(+), 202 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 5f435e363..03a222f9b 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -330,30 +330,28 @@ class CI_DB_driver { // This will trigger a rollback if transactions are being used $this->_trans_status = FALSE; - // Grab the error number and message now, as we might run some - // additional queries before displaying the error - $error_no = $this->_error_number(); - $error_msg = $this->_error_message(); + // Grab the error now, as we might run some additional queries before displaying the error + $error = $this->error(); // Log errors - log_message('error', 'Query error: '.$error_msg); + log_message('error', 'Query error: '.$error['message']); if ($this->db_debug) { // We call this function in order to roll-back queries - // if transactions are enabled. If we don't call this here + // if transactions are enabled. If we don't call this here // the error message will trigger an exit, causing the // transactions to remain in limbo. $this->trans_complete(); // Display errors return $this->display_error( - array( - 'Error Number: '.$error_no, - $error_msg, - $sql - ) - ); + array( + 'Error Number: '.$error['code'], + $error['message'], + $sql + ) + ); } return FALSE; diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 42f08fbf6..cb33919a4 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -453,31 +453,18 @@ class CI_DB_cubrid_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @access private - * @return string - */ - function _error_message() - { - return cubrid_error($this->conn_id); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @access private - * @return integer + * @return array */ - function _error_number() + public function error() { - return cubrid_errno($this->conn_id); + return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id)); } - // -------------------------------------------------------------------- - /** * Escape the SQL Identifiers * diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 2a4f2b575..188c91f9b 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -438,28 +438,18 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @access private - * @return string - */ - function _error_message() - { - return mssql_get_last_message(); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @access private - * @return integer + * @return array */ - function _error_number() + public function error() { - // Are error numbers supported? - return ''; + $query = $this->query('SELECT @@ERROR AS code'); + $query = $query->row(); + return array('code' => $query->code, 'message' => mssql_get_last_message()); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index c88a8a766..a7f08d1a8 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -417,25 +417,16 @@ class CI_DB_mysql_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @return string - */ - protected function _error_message() - { - return mysql_error($this->conn_id); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @return int + * @return array */ - protected function _error_number() + public function error() { - return mysql_errno($this->conn_id); + return array('code' => mysql_errno($this->conn_id), 'message' => mysql_error($this->conn_id)); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index dbba12e15..031371345 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -418,25 +418,16 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @return string - */ - protected function _error_message() - { - return mysqli_error($this->conn_id); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @return int + * @return array */ - protected function _error_number() + public function error() { - return mysqli_errno($this->conn_id); + return array('code' => mysqli_errno($this->conn_id), 'message' => mysqli_error($this->conn_id)); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 6da6dc724..97efb4647 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -527,39 +527,18 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @return string - */ - protected function _error_message() - { - $error = $this->_oci8_error_data(); - return $error['message']; - } - - // -------------------------------------------------------------------- - - /** - * The error message number - * - * @return string - */ - protected function _error_number() - { - $error = $this->_oci8_error_data(); - return $error['code']; - } - - // -------------------------------------------------------------------- - - /** - * OCI8-specific method to get errors. - * Used by _error_message() and _error_code(). + * Returns an array containing code and message of the last + * database error that has occured. * * @return array */ - protected function _oci8_error_data() + public function error() { + /* oci_error() returns an array that already contains the + * 'code' and 'message' keys, so we can just return it. + */ if (is_resource($this->curs_id)) { return oci_error($this->curs_id); diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index abb660324..5a93f7cad 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -398,27 +398,16 @@ class CI_DB_odbc_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @access private - * @return string - */ - function _error_message() - { - return odbc_errormsg($this->conn_id); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @access private - * @return integer + * @return array */ - function _error_number() + public function error() { - return odbc_error($this->conn_id); + return array('code' => odbc_error($this->conn_id), 'message' => odbc_errormsg($this->conn_id)); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 90f0fd791..de5e1f05e 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -609,29 +609,30 @@ class CI_DB_pdo_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @access private - * @return string + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array */ - function _error_message() + public function error() { - $error_array = $this->conn_id->errorInfo(); + $error = array('code' => '00000', 'message' => ''); + $pdo_error = $this->conn_id->errorInfo(); - return $error_array[2]; - } + if (empty($pdo_error[0])) + { + return $error; + } - // -------------------------------------------------------------------- + $error['code'] = isset($pdo_error[1]) ? $pdo_error[0].'/'.$pdo_error[1] : $pdo_error[0]; + if (isset($pdo_error[2])) + { + $error['message'] = $pdo_error[2]; + } - /** - * The error message number - * - * @access private - * @return integer - */ - function _error_number() - { - return $this->conn_id->errorCode(); + return $error; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 89541e5fa..0fcd954e9 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -443,27 +443,16 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @access private - * @return string - */ - function _error_message() - { - return pg_last_error($this->conn_id); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @access private - * @return integer + * @return array */ - function _error_number() + public function error() { - return ''; + return array('code' => '', 'message' => pg_last_error($this->conn_id)); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 718501b20..3e4b37320 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -412,27 +412,18 @@ class CI_DB_sqlite_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @access private - * @return string - */ - function _error_message() - { - return sqlite_error_string(sqlite_last_error($this->conn_id)); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @access private - * @return integer + * @return array */ - function _error_number() + public function error() { - return sqlite_last_error($this->conn_id); + $error = array('code' => sqlite_last_error($this->conn_id)); + $error['message'] = sqlite_error_string($error['code']); + return $error; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 9b9038189..03d7c7199 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -406,46 +406,39 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @return string + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array */ - protected function _error_message() + public function error() { - $error = sqlsrv_errors(); - if ( ! is_array($error)) + $error = array('code' => '00000', 'message' => ''); + $sqlsrv_errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); + + if ( ! is_array($sqlsrv_errors)) { - return ''; + return $error; } - $error = array_shift($error); - return isset($error['message']) ? $error['message'] : ''; - } - - // -------------------------------------------------------------------- - - /** - * The error message number - * - * @return string - */ - protected function _error_number() - { - $error = sqlsrv_errors(); - if ( ! is_array($error)) + $sqlsrv_error = array_shift($sqlsrv_errors); + if (isset($sqlsrv_error['SQLSTATE'])) { - return ''; + $error['code'] = isset($sqlsrv_error['code']) ? $sqlsrv_error['SQLSTATE'].'/'.$sqlsrv_error['code'] : $sqlsrv_error['SQLSTATE']; } - elseif (isset($error['SQLSTATE'])) + elseif (isset($sqlsrv_error['code'])) { - return isset($error['code']) ? $error['SQLSTATE'].'/'.$error['code'] : $error['SQLSTATE']; + $error['code'] = $sqlsrv_error['code']; } - elseif (isset($error['code'])) + + if (isset($sqlsrv_error['message'])) { - return $error['code']; + $error['message'] = $sqlsrv_error['message']; } - return ''; + return $error; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 00df2e3183dc1cbef82dafe6cc432d73fe659ae9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 18:37:16 +0200 Subject: Replace Interbase _error_message(), _error_number() with the new error() method --- .../drivers/interbase/interbase_driver.php | 48 +++++++++------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 4dca7c8a9..17fcffa65 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -58,7 +58,7 @@ class CI_DB_interbase_driver extends CI_DB { */ protected $_count_string = "SELECT COUNT(*) AS "; protected $_random_keyword = ' Random()'; // database specific random keyword - + // Keeps track of the resource for the current transaction protected $trans; @@ -139,12 +139,12 @@ class CI_DB_interbase_driver extends CI_DB { if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) { $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); - + // Don't keep the service open ibase_service_detach($service); return $version; } - + return FALSE; } @@ -203,7 +203,7 @@ class CI_DB_interbase_driver extends CI_DB { $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; $this->trans = @ibase_trans($this->conn_id); - + return TRUE; } @@ -226,7 +226,7 @@ class CI_DB_interbase_driver extends CI_DB { { return TRUE; } - + return @ibase_commit($this->trans); } @@ -398,7 +398,7 @@ SQL; protected function _field_data($table) { // Need to find a more efficient way to do this - // but Interbase/Firebird seems to lack the + // but Interbase/Firebird seems to lack the // limit clause return "SELECT * FROM {$table}"; } @@ -406,25 +406,16 @@ SQL; // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @return string - */ - protected function _error_message() - { - return ibase_errmsg(); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @return integer + * @return array */ - protected function _error_number() + public function error() { - return ibase_errcode(); + return array('code' => ibase_errcode(), 'message' => ibase_errmsg()); } // -------------------------------------------------------------------- @@ -603,12 +594,12 @@ SQL; { // Keep the current sql string safe for a moment $orig_sql = $sql; - + // Limit clause depends on if Interbase or Firebird if (stripos($this->_version(), 'firebird') !== FALSE) { $sql = 'FIRST '. (int) $limit; - + if ($offset > 0) { $sql .= ' SKIP '. (int) $offset; @@ -617,16 +608,14 @@ SQL; else { $sql = 'ROWS ' . (int) $limit; - + if ($offset > 0) { $sql = 'ROWS '. (int) $offset . ' TO ' . ($limit + $offset); } } - - $sql = preg_replace("`SELECT`i", "SELECT {$sql}", $orig_sql); - - return $sql; + + return preg_replace('`SELECT`i', "SELECT {$sql}", $orig_sql); } // -------------------------------------------------------------------- @@ -641,7 +630,8 @@ SQL; { @ibase_close($conn_id); } + } /* End of file interbase_driver.php */ -/* Location: ./system/database/drivers/interbase/interbase_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/interbase/interbase_driver.php */ -- cgit v1.2.3-24-g4f1b From f142192a97033c4f8d398212443bc4776bd2ca98 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 2 Mar 2012 11:51:42 -0500 Subject: Limit db session select to single row --- system/libraries/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 66b39a6a2..dd50a91e1 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -219,7 +219,7 @@ class CI_Session { $this->CI->db->where('user_agent', $session['user_agent']); } - $query = $this->CI->db->get($this->sess_table_name); + $query = $this->CI->db->limit(1)->get($this->sess_table_name); // No result? Kill it! if ($query->num_rows() === 0) -- cgit v1.2.3-24-g4f1b From 7fcc7bdf7eb9c65920b1e14f242e31e3d71d1fd0 Mon Sep 17 00:00:00 2001 From: Diogo Osório Date: Fri, 2 Mar 2012 16:54:52 +0000 Subject: #1080 - Check if the SMTP connection and authentication were successfull. --- system/libraries/Email.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index c8a5b41af..39a7059dd 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1359,6 +1359,7 @@ class CI_Email { if ( ! $this->$method()) { $this->_set_error_message('lang:email_send_failure_' . ($this->_get_protocol() === 'mail' ? 'phpmail' : $this->_get_protocol())); + return FALSE; } $this->_set_error_message('lang:email_sent', $this->_get_protocol()); @@ -1433,8 +1434,10 @@ class CI_Email { return FALSE; } - $this->_smtp_connect(); - $this->_smtp_authenticate(); + if ( !($this->_smtp_connect() && $this->_smtp_authenticate()) ) + { + return FALSE; + } $this->_send_command('from', $this->clean_email($this->_headers['From'])); -- cgit v1.2.3-24-g4f1b From 78ca39bc8c4b7edf0468e4a0a7251f808f352414 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 19:04:31 +0200 Subject: Removed db_set_charset() from Interbase driver (no longer needed) --- system/database/drivers/interbase/interbase_driver.php | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 17fcffa65..51e814e16 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -114,21 +114,6 @@ class CI_DB_interbase_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Set client character set - * - * @param string - * @param string - * @return bool - */ - public function db_set_charset($charset, $collation) - { - // Must be determined at connection - return TRUE; - } - - // -------------------------------------------------------------------- - /** * Version number query string * -- cgit v1.2.3-24-g4f1b From 593f798a0b463f45e00a207e4fe4b8cc82dedc35 Mon Sep 17 00:00:00 2001 From: Diogo Osório Date: Fri, 2 Mar 2012 18:04:17 +0000 Subject: Made the code more readable, updated the changelog. --- system/libraries/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 39a7059dd..8d839d0c9 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1434,7 +1434,7 @@ class CI_Email { return FALSE; } - if ( !($this->_smtp_connect() && $this->_smtp_authenticate()) ) + if ( ! $this->_smtp_connect() OR ! $this->_smtp_authenticate()) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 100934cf6d8d3bc3bcff7c7a16d0d2c29bf2f6a9 Mon Sep 17 00:00:00 2001 From: Mike Davies Date: Fri, 2 Mar 2012 19:18:22 -0500 Subject: Updated tabs, reinserted license, and fixed logic on get() --- system/libraries/Cache/drivers/Cache_wincache.php | 62 ++++++++++++++--------- 1 file changed, 37 insertions(+), 25 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index a1b1bb3de..8164b5a7b 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -4,13 +4,25 @@ * * An open source application development framework for PHP 5.1.6 or newer * + * NOTICE OF LICENSE + * + * Licensed under the Open Software License version 3.0 + * + * 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. + * * @package CodeIgniter - * @author Mike Murkovic - * @copyright - * @license http://codeigniter.com/user_guide/license.html + * @author EllisLab Dev Team + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 2.0 - * @filesource + * @filesource */ // ------------------------------------------------------------------------ @@ -41,11 +53,11 @@ class CI_Cache_wincache extends CI_Driver { */ public function get($id) { - if ($data = wincache_ucache_get($id)) - { - return $data; - } - return FALSE; + $success = FALSE; + $data = wincache_ucache_get($id, $success); + + //Success returned by reference from wincache_ucache_get + return ($success) ? $data : FALSE; } // ------------------------------------------------------------------------ @@ -111,20 +123,20 @@ class CI_Cache_wincache extends CI_Driver { */ public function get_metadata($id) { - if ($stored = wincache_ucache_info(false, $id)) - { - $age = $stored['ucache_entries'][1]['age_seconds']; - $ttl = $stored['ucache_entries'][1]['ttl_seconds']; - $hitcount = $stored['ucache_entries'][1]['hitcount']; - - return array( - 'expire' => $ttl - $age, - 'hitcount' => $hitcount, - 'age' => $age, - 'ttl' => $ttl - ); - } - return false; + if ($stored = wincache_ucache_info(false, $id)) + { + $age = $stored['ucache_entries'][1]['age_seconds']; + $ttl = $stored['ucache_entries'][1]['ttl_seconds']; + $hitcount = $stored['ucache_entries'][1]['hitcount']; + + return array( + 'expire' => $ttl - $age, + 'hitcount' => $hitcount, + 'age' => $age, + 'ttl' => $ttl + ); + } + return false; } // ------------------------------------------------------------------------ @@ -138,8 +150,8 @@ class CI_Cache_wincache extends CI_Driver { { if ( ! extension_loaded('wincache') ) { - log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); - return FALSE; + log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); + return FALSE; } return TRUE; -- cgit v1.2.3-24-g4f1b From 08856b8738ea4fc17b13986c9f2619383cb4a6e9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Mar 2012 03:19:28 +0200 Subject: Improve DB version() implementation and add pg_version() support --- system/database/DB_driver.php | 46 ++++++++++++---------- system/database/drivers/cubrid/cubrid_driver.php | 14 +++---- .../drivers/interbase/interbase_driver.php | 15 ++++--- system/database/drivers/mssql/mssql_driver.php | 7 ++-- system/database/drivers/mysql/mysql_driver.php | 8 ++-- system/database/drivers/mysqli/mysqli_driver.php | 8 ++-- system/database/drivers/oci8/oci8_driver.php | 11 +++--- system/database/drivers/odbc/odbc_driver.php | 13 ------ system/database/drivers/pdo/pdo_driver.php | 10 +++-- system/database/drivers/postgre/postgre_driver.php | 27 ++++++++++--- system/database/drivers/sqlite/sqlite_driver.php | 9 +++-- system/database/drivers/sqlite/sqlite_forge.php | 4 +- system/database/drivers/sqlsrv/sqlsrv_driver.php | 24 +++++++---- 13 files changed, 109 insertions(+), 87 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 075cab2c9..b41a42051 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -222,36 +222,40 @@ class CI_DB_driver { // -------------------------------------------------------------------- /** - * Database Version Number. Returns a string containing the - * version of the database being used + * Database version number + * + * Returns a string containing the version of the database being used. + * Most drivers will override this method. * - * @access public * @return string */ - function version() + public function version() { - if (FALSE === ($sql = $this->_version())) + if (isset($this->data_cache['version'])) { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; + return $this->data_cache['version']; } - // Some DBs have functions that return the version, and don't run special - // SQL queries per se. In these instances, just return the result. - $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli', 'interbase'); - - if (in_array($this->dbdriver, $driver_version_exceptions)) - { - return $sql; - } - else + if (FALSE === ($sql = $this->_version())) { - $query = $this->query($sql); - return $query->row('ver'); + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; } + + $query = $this->query($sql); + $query = $query->row(); + return $this->data_cache['version'] = $query->ver; + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @return string + */ + protected function _version() + { + return 'SELECT VERSION() AS ver'; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index cb33919a4..afdaef351 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -156,19 +156,15 @@ class CI_DB_cubrid_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * - * @access public * @return string */ - function _version() + public function version() { - // To obtain the CUBRID Server version, no need to run the SQL query. - // CUBRID PHP API provides a function to determin this value. - // This is why we also need to add 'cubrid' value to the list of - // $driver_version_exceptions array in DB_driver class in - // version() function. - return cubrid_get_server_info($this->conn_id); + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = cubrid_get_server_info($this->conn_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 51e814e16..f4bd9e271 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -115,19 +115,24 @@ class CI_DB_interbase_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * * @return string */ - protected function _version() + public function version() { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) { - $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); + $this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); // Don't keep the service open ibase_service_detach($service); - return $version; + return $this->data_cache['version']; } return FALSE; @@ -581,7 +586,7 @@ SQL; $orig_sql = $sql; // Limit clause depends on if Interbase or Firebird - if (stripos($this->_version(), 'firebird') !== FALSE) + if (stripos($this->version(), 'firebird') !== FALSE) { $sql = 'FIRST '. (int) $limit; diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 188c91f9b..147c63483 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -339,12 +339,11 @@ class CI_DB_mssql_driver extends CI_DB { /** * Version number query string * - * @access public - * @return string + * @return string */ - function _version() + protected function _version() { - return "SELECT @@VERSION AS ver"; + return 'SELECT @@VERSION AS ver'; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index a7f08d1a8..7108a6db1 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -157,13 +157,15 @@ class CI_DB_mysql_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * * @return string */ - protected function _version() + public function version() { - return 'SELECT version() AS ver'; + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = @mysql_get_server_info($this->conn_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 031371345..19353944d 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -157,13 +157,15 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * * @return string */ - protected function _version() + public function version() { - return @mysqli_get_server_info($this->conn_id); + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = @mysqli_get_server_info($this->conn_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 97efb4647..35cafff6c 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -139,14 +139,15 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * - * @access protected - * @return string + * @return string */ - protected function _version() + public function version() { - return oci_server_version($this->conn_id); + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = oci_server_version($this->conn_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 5a93f7cad..779b0c62f 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -123,19 +123,6 @@ class CI_DB_odbc_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Version number query string - * - * @access public - * @return string - */ - function _version() - { - return "SELECT version() AS ver"; - } - - // -------------------------------------------------------------------- - /** * Execute the query * diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index de5e1f05e..8fdfd58fb 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -289,13 +289,15 @@ class CI_DB_pdo_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * * @return string */ - protected function _version() + public function version() { - return $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION); + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION); } // -------------------------------------------------------------------- @@ -499,7 +501,7 @@ class CI_DB_pdo_driver extends CI_DB { */ public function insert_id($name = NULL) { - if ($this->pdodriver === 'pgsql' && $name === NULL && $this->_version() >= '8.1') + if ($this->pdodriver === 'pgsql' && $name === NULL && $this->version() >= '8.1') { $query = $this->query('SELECT LASTVAL() AS ins_id'); $query = $query->row(); diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 0fcd954e9..d6681086a 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -147,14 +147,30 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * - * @access public * @return string */ - function _version() + public function version() { - return "SELECT version() AS ver"; + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + + if (($pg_version = pg_version($this->conn_id)) === FALSE) + { + return FALSE; + } + + /* If PHP was compiled with PostgreSQL lib versions earlier + * than 7.4, pg_version() won't return the server version + * and so we'll have to fall back to running a query in + * order to get it. + */ + return isset($pg_version['server']) + ? $this->data_cache['version'] = $pg_version['server'] + : parent::version(); } // -------------------------------------------------------------------- @@ -323,8 +339,7 @@ class CI_DB_postgre_driver extends CI_DB { */ function insert_id() { - $v = $this->_version(); - $v = $v['server']; + $v = $this->version(); $table = func_num_args() > 0 ? func_get_arg(0) : NULL; $column = func_num_args() > 1 ? func_get_arg(1) : NULL; diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 3e4b37320..3eaec949c 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -141,14 +141,15 @@ class CI_DB_sqlite_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * - * @access public * @return string */ - function _version() + public function version() { - return sqlite_libversion(); + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = sqlite_libversion(); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 2b723be0b..fd0f3eb98 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -89,7 +89,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { $sql = 'CREATE TABLE '; // IF NOT EXISTS added to SQLite in 3.3.0 - if ($if_not_exists === TRUE && version_compare($this->db->_version(), '3.3.0', '>=') === TRUE) + if ($if_not_exists === TRUE && version_compare($this->db->version(), '3.3.0', '>=') === TRUE) { $sql .= 'IF NOT EXISTS '; } @@ -274,4 +274,4 @@ class CI_DB_sqlite_forge extends CI_DB_forge { } /* End of file sqlite_forge.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 03d7c7199..5c90cb4f2 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -317,15 +317,23 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string - * - * @access public - * @return string - */ - function _version() + * Database version number + * + * @return string + */ + public function version() { - $info = sqlsrv_server_info($this->conn_id); - return sprintf("select '%s' as ver", $info['SQLServerVersion']); + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + + if (($info = sqlsrv_server_info($this->conn_id)) === FALSE) + { + return FALSE; + } + + return $this->data_cache['version'] = $info['SQLServerVersion']; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 8e89df8f92444eb02dc73b6c3e66077a4fb3f710 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Mar 2012 03:48:12 +0200 Subject: Add db_set_charset() support for PostgreSQL and change its implementation for 'mysql' --- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/postgre/postgre_driver.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7108a6db1..84f7791c7 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -147,7 +147,7 @@ class CI_DB_mysql_driver extends CI_DB { * @param string * @return bool */ - public function db_set_charset($charset, $collation) + protected function _db_set_charset($charset, $collation) { return function_exists('mysql_set_charset') ? @mysql_set_charset($charset, $this->conn_id) diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index d6681086a..8df90f6a4 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -146,6 +146,19 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- + /** + * Set client character set + * + * @param string + * @return bool + */ + protected function _db_set_charset($charset) + { + return (pg_set_client_encoding($this->conn_id, $charset) === 0); + } + + // -------------------------------------------------------------------- + /** * Database version number * -- cgit v1.2.3-24-g4f1b From 5fa729827d63774457ad34b57109a2f6ab20d20f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Mar 2012 04:13:20 +0200 Subject: Added _optimize_table() support for PostgreSQL --- system/database/DB_driver.php | 2 +- .../database/drivers/postgre/postgre_utility.php | 35 ++++++++-------------- 2 files changed, 13 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index b41a42051..15195b20a 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -651,7 +651,7 @@ class CI_DB_driver { */ public function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|OPTIMIZE)\s+/i', $sql); + return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|OPTIMIZE|REINDEX)\s+/i', $sql); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index dffd8c549..c426b363b 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -1,13 +1,13 @@ -db->protect_identifiers($table); } // -------------------------------------------------------------------- @@ -68,13 +62,10 @@ class CI_DB_postgre_utility extends CI_DB_utility { /** * Repair table query * - * Are table repairs supported in Postgre? - * - * @access private * @param string the table name - * @return object + * @return bool */ - function _repair_table($table) + public function _repair_table($table) { return FALSE; } @@ -84,7 +75,6 @@ class CI_DB_postgre_utility extends CI_DB_utility { /** * Postgre Export * - * @access private * @param array Preferences * @return mixed */ @@ -95,6 +85,5 @@ class CI_DB_postgre_utility extends CI_DB_utility { } } - /* End of file postgre_utility.php */ -/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file +/* Location: ./system/database/drivers/postgre/postgre_utility.php */ -- cgit v1.2.3-24-g4f1b From a19beb0c580ac78c4b75548a046240a85f30cb29 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Mar 2012 04:20:50 +0200 Subject: Replace usage of legacy alias pg_exec() in favor of pg_query() and improve PostgreSQL driver trans_*() methods --- system/database/drivers/postgre/postgre_driver.php | 38 ++++++---------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 8df90f6a4..df0f50da5 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -222,18 +222,12 @@ class CI_DB_postgre_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } @@ -241,9 +235,9 @@ class CI_DB_postgre_driver extends CI_DB { // Reset the transaction failure flag. // If the $test_mode flag is set to TRUE transactions will be rolled back // even if the queries produce a successful result. - $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + $this->_trans_failure = ($test_mode === TRUE); - return @pg_exec($this->conn_id, "begin"); + return @pg_query($this->conn_id, 'BEGIN'); } // -------------------------------------------------------------------- @@ -251,23 +245,17 @@ class CI_DB_postgre_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } - return @pg_exec($this->conn_id, "commit"); + return @pg_query($this->conn_id, 'COMMIT'); } // -------------------------------------------------------------------- @@ -275,23 +263,17 @@ class CI_DB_postgre_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } - return @pg_exec($this->conn_id, "rollback"); + return @pg_query($this->conn_id, 'ROLLBACK'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3722e50439fd88281f8730fd329b41812cd19963 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Mar 2012 15:04:38 +0200 Subject: Fix MySQL/MySQLi field_data() --- system/database/drivers/mysql/mysql_driver.php | 31 +++++++++++++++++++----- system/database/drivers/mysqli/mysqli_driver.php | 31 +++++++++++++++++++----- 2 files changed, 50 insertions(+), 12 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 84f7791c7..7fd08a6ed 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -404,16 +404,35 @@ class CI_DB_mysql_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Field data query - * - * Generates a platform-specific query so that the column data can be retrieved + * Returns an object with field data * * @param string the table name - * @return string + * @return object */ - public function _field_data($table) + public function field_data($table = '') { - return 'DESCRIBE '.$table; + if ($table == '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $query = $this->query('DESCRIBE '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + preg_match('/([a-z]+)(\(\d+\))?/', $query[$i]->Type, $matches); + + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->Field; + $retval[$i]->type = empty($matches[1]) ? NULL : $matches[1]; + $retval[$i]->default = $query[$i]->Default; + $retval[$i]->max_length = empty($matches[2]) ? NULL : preg_replace('/[^\d]/', '', $matches[2]); + $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI'); + } + + return $retval; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 19353944d..25b6ceca1 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -405,16 +405,35 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Field data query - * - * Generates a platform-specific query so that the column data can be retrieved + * Returns an object with field data * * @param string the table name - * @return string + * @return object */ - protected function _field_data($table) + public function field_data($table = '') { - return 'DESCRIBE '.$table; + if ($table == '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $query = $this->query('DESCRIBE '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + preg_match('/([a-z]+)(\(\d+\))?/', $query[$i]->Type, $matches); + + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->Field; + $retval[$i]->type = empty($matches[1]) ? NULL : $matches[1]; + $retval[$i]->default = $query[$i]->Default; + $retval[$i]->max_length = empty($matches[2]) ? NULL : preg_replace('/[^\d]/', '', $matches[2]); + $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI'); + } + + return $retval; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3edd88eee84886fc6ba3e1fc25beda3c424370bc Mon Sep 17 00:00:00 2001 From: tubalmartin Date: Sat, 3 Mar 2012 22:10:34 +0100 Subject: An even better url_title helper. Tests: http://codepad.org/tuJgvkyN Changelog entry added for 2.1.1 --- system/helpers/url_helper.php | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'system') diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 9f4b85248..cdb6dae9c 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -478,27 +478,14 @@ if ( ! function_exists('url_title')) { function url_title($str, $separator = 'dash', $lowercase = FALSE) { - if ($separator == 'dash') - { - $search = '_'; - $replace = '-'; - } - else - { - $search = '-'; - $replace = '_'; - } + $replace = $separator == 'dash' ? '-' : '_'; $trans = array( - '&\#\d+?;' => '', - '&\S+?;' => '', - '\s+' => $replace, - '[^a-z0-9\-\._]' => '', - $replace.'+' => $replace, - $replace.'$' => $replace, - '^'.$replace => $replace, - '\.+$' => '' - ); + '&.+?;' => '', + '[^a-z0-9 _-]' => '', + '\s+' => $replace, + $replace.'+' => $replace + ); $str = strip_tags($str); @@ -512,7 +499,7 @@ if ( ! function_exists('url_title')) $str = strtolower($str); } - return trim(stripslashes($str)); + return trim($str, $replace); } } -- cgit v1.2.3-24-g4f1b From 010f1f4b315c8f5aef2e0b4c6571e4c4752f56c6 Mon Sep 17 00:00:00 2001 From: tubalmartin Date: Sat, 3 Mar 2012 22:24:31 +0100 Subject: Fixed a bug - CI_Upload::_file_mime_type() could've failed if popen() is used for the detection. --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 91fbf66ca..b0490de30 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1095,7 +1095,7 @@ class CI_Upload { $proc = @popen($cmd, 'r'); if (is_resource($proc)) { - $mime = @fread($test, 512); + $mime = @fread($proc, 512); @pclose($proc); if ($mime !== FALSE) { -- cgit v1.2.3-24-g4f1b From f8f04ce990a46f1967cd58def4929c476f4595a5 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sun, 4 Mar 2012 14:21:12 +0000 Subject: Fixed conflicts. --- system/helpers/form_helper.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index bed2cb297..6efef2324 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -22,7 +22,6 @@ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 - * @filesource */ // ------------------------------------------------------------------------ @@ -72,8 +71,8 @@ if ( ! function_exists('form_open')) $form = '
\n"; - // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites - if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"'))) + // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites + if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"'))) { $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } -- cgit v1.2.3-24-g4f1b From 099c478b2ebafd0a1b74e76221ed06c214e195f4 Mon Sep 17 00:00:00 2001 From: JonoB Date: Sun, 4 Mar 2012 14:37:30 +0000 Subject: Allow users to specify an array for validation, instead of alway using the $_POST array --- system/libraries/Form_validation.php | 67 +++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 12 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 5069a44c1..b3efe82cf 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -47,7 +47,8 @@ class CI_Form_validation { protected $_error_suffix = '

'; protected $error_string = ''; protected $_safe_form_data = FALSE; - + protected $validation_data = array(); + /** * Constructor */ @@ -84,8 +85,9 @@ class CI_Form_validation { */ public function set_rules($field, $label = '', $rules = '') { - // No reason to set rules if we have no POST data - if (count($_POST) === 0) + // No reason to set rules if we have no POST data + // or a validation array has not been specified + if (count($_POST) === 0 && count($this->validation_data) === 0) { return $this; } @@ -159,13 +161,31 @@ class CI_Form_validation { return $this; } + // -------------------------------------------------------------------- + + /** + * By default, form validation uses the $_POST array to validate + * + * If an array is set through this method, then this array will + * be used instead of the $_POST array + * + * @param array $data + */ + public function set_data($data = '') + { + if ( ! empty($data) && is_array($data)) + { + $this->validation_data = $data; + } + } + // -------------------------------------------------------------------- /** * Set Error Message * * Lets users set their own error messages on the fly. Note: The key - * name has to match the function name that it corresponds to. + * name has to match the function name that it corresponds to. * * @param string * @param string @@ -300,10 +320,14 @@ class CI_Form_validation { public function run($group = '') { // Do we even have any data to process? Mm? - if (count($_POST) === 0) + $validation_array = ( ! empty($this->validation_data)) ? $this->validation_data : $_POST; + if (count($validation_array) === 0) { return FALSE; } + + // Clear any previous validation data + $this->_reset_validation(); // Does the _field_data array containing the validation rules exist? // If not, we look to see if they were assigned via a config file @@ -342,18 +366,18 @@ class CI_Form_validation { // corresponding $_POST item and test for errors foreach ($this->_field_data as $field => $row) { - // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. + // Fetch the data from the corresponding $_POST or validation array and cache it in the _field_data array. // Depending on whether the field name is an array or a string will determine where we get it from. if ($row['is_array'] === TRUE) { - $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); + $this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']); } else { - if (isset($_POST[$field]) AND $_POST[$field] != "") + if (isset($validation_array[$field]) AND $validation_array[$field] != "") { - $this->_field_data[$field]['postdata'] = $_POST[$field]; + $this->_field_data[$field]['postdata'] = $validation_array[$field]; } } @@ -867,12 +891,13 @@ class CI_Form_validation { */ public function matches($str, $field) { - if ( ! isset($_POST[$field])) + $validation_array = ( ! empty($this->validation_data)) ? $this->validation_data : $_POST; + if ( ! isset($validation_array[$field])) { return FALSE; } - return ($str === $_POST[$field]); + return ($str === $validation_array[$field]); } // -------------------------------------------------------------------- @@ -1282,7 +1307,25 @@ class CI_Form_validation { { return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); } - + + // -------------------------------------------------------------------- + + /** + * Reset validation vars + * + * Prevents subsequent validation routines from being affected by the + * results of any previous validation routine due to the CI singleton. + * + * @return void + */ + protected function _reset_validation() + { + $this->_field_data = array(); + $this->_config_rules = array(); + $this->_error_array = array(); + $this->_error_messages = array(); + $this->error_string = ''; + } } /* End of file Form_validation.php */ -- cgit v1.2.3-24-g4f1b From 1a6971030718e2e92e6fc80750f7a14faf035257 Mon Sep 17 00:00:00 2001 From: tubalmartin Date: Sun, 4 Mar 2012 16:01:11 +0100 Subject: Allow developers to use any string as a separator, not just dashes or underscores. Backwards compatible when using 'dash' or 'underscore' as string separator. Tests: http://codepad.org/DWcxVH5r --- system/helpers/url_helper.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'system') diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index cdb6dae9c..f1e8c6ac6 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -466,25 +466,34 @@ if ( ! function_exists('prep_url')) * Create URL Title * * Takes a "title" string as input and creates a - * human-friendly URL string with either a dash - * or an underscore as the word separator. + * human-friendly URL string with a "separator" string + * as the word separator. * * @access public * @param string the string - * @param string the separator: dash, or underscore + * @param string the separator * @return string */ if ( ! function_exists('url_title')) { - function url_title($str, $separator = 'dash', $lowercase = FALSE) + function url_title($str, $separator = '-', $lowercase = FALSE) { - $replace = $separator == 'dash' ? '-' : '_'; + if ($separator == 'dash') + { + $separator = '-'; + } + else if ($separator == 'underscore') + { + $separator = '_'; + } + + $q_separator = preg_quote($separator); $trans = array( - '&.+?;' => '', - '[^a-z0-9 _-]' => '', - '\s+' => $replace, - $replace.'+' => $replace + '&.+?;' => '', + '[^a-z0-9 _-]' => '', + '\s+' => $separator, + '('.$q_separator.')+' => $separator ); $str = strip_tags($str); @@ -499,7 +508,7 @@ if ( ! function_exists('url_title')) $str = strtolower($str); } - return trim($str, $replace); + return trim($str, $separator); } } -- cgit v1.2.3-24-g4f1b From c8da4fe74d9cb0d456a18316fa9a0879d50e33f4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 4 Mar 2012 19:20:33 +0200 Subject: Fix indentation for changes from pull #1121 --- system/libraries/Form_validation.php | 49 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index b3efe82cf..1c0089d85 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -48,10 +48,7 @@ class CI_Form_validation { protected $error_string = ''; protected $_safe_form_data = FALSE; protected $validation_data = array(); - - /** - * Constructor - */ + public function __construct($rules = array()) { $this->CI =& get_instance(); @@ -85,7 +82,7 @@ class CI_Form_validation { */ public function set_rules($field, $label = '', $rules = '') { - // No reason to set rules if we have no POST data + // No reason to set rules if we have no POST data // or a validation array has not been specified if (count($_POST) === 0 && count($this->validation_data) === 0) { @@ -162,23 +159,24 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + /** * By default, form validation uses the $_POST array to validate - * + * * If an array is set through this method, then this array will * be used instead of the $_POST array - * - * @param array $data + * + * @param array $data + * @return void */ public function set_data($data = '') { if ( ! empty($data) && is_array($data)) { - $this->validation_data = $data; + $this->validation_data = $data; } } - + // -------------------------------------------------------------------- /** @@ -325,7 +323,7 @@ class CI_Form_validation { { return FALSE; } - + // Clear any previous validation data $this->_reset_validation(); @@ -891,7 +889,7 @@ class CI_Form_validation { */ public function matches($str, $field) { - $validation_array = ( ! empty($this->validation_data)) ? $this->validation_data : $_POST; + $validation_array = ( ! empty($this->validation_data)) ? $this->validation_data : $_POST; if ( ! isset($validation_array[$field])) { return FALSE; @@ -1307,25 +1305,26 @@ class CI_Form_validation { { return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); } - + // -------------------------------------------------------------------- - - /** - * Reset validation vars - * - * Prevents subsequent validation routines from being affected by the + + /** + * Reset validation vars + * + * Prevents subsequent validation routines from being affected by the * results of any previous validation routine due to the CI singleton. - * - * @return void - */ - protected function _reset_validation() - { + * + * @return void + */ + protected function _reset_validation() + { $this->_field_data = array(); $this->_config_rules = array(); $this->_error_array = array(); $this->_error_messages = array(); $this->error_string = ''; - } + } + } /* End of file Form_validation.php */ -- cgit v1.2.3-24-g4f1b From cc5af53346397846f2035dc2bf6a2c2f9b0cd4ab Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 5 Mar 2012 14:02:15 +0200 Subject: Fix issue #1125 --- system/database/drivers/odbc/odbc_result.php | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index 572e110ca..2d5b50a8d 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -245,8 +245,42 @@ class CI_DB_odbc_result extends CI_DB_result { return $rs_assoc; } -} + // -------------------------------------------------------------------- + + /** + * Query result. Array version. + * + * @return array + */ + public function result_array() + { + if (count($this->result_array) > 0) + { + return $this->result_array; + } + elseif (($c = count($this->result_object)) > 0) + { + for ($i = 0; $i < $c; $i++) + { + $this->result_array[$i] = (array) $this->result_object[$i]; + } + } + elseif ($this->result_id === FALSE) + { + return array(); + } + else + { + while ($row = $this->_fetch_assoc()) + { + $this->result_array[] = $row; + } + } + return $this->result_array; + } + +} /* End of file odbc_result.php */ /* Location: ./system/database/drivers/odbc/odbc_result.php */ -- cgit v1.2.3-24-g4f1b From 8af76666474c42b45518c08bec16b4f8d700dd3c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 5 Mar 2012 14:33:41 +0200 Subject: Partially fix issue #306 --- system/database/drivers/odbc/odbc_driver.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 779b0c62f..a6e08cf2f 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -287,12 +287,11 @@ class CI_DB_odbc_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * @return bool */ - function insert_id() + public function insert_id() { - return @odbc_insert_id($this->conn_id); + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 57bdeb61bf199d1ae3ceaede4e9a9af8290ce715 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 5 Mar 2012 15:59:16 +0200 Subject: Removed oci8-specific stuff from DB_driver.php and added a constructor to DB_result to handle initialization --- system/database/DB_driver.php | 22 ++-------------------- system/database/DB_result.php | 6 ++++++ system/database/drivers/oci8/oci8_result.php | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 23 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index e403efb9f..a61450d4c 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -77,12 +77,6 @@ class CI_DB_driver { var $_protect_identifiers = TRUE; var $_reserved_identifiers = array('*'); // Identifiers that should NOT be escaped - // These are use with Oracle - var $stmt_id; - var $curs_id; - var $limit_used; - - /** * Constructor. Accepts one parameter containing the database * connection settings. @@ -396,21 +390,9 @@ class CI_DB_driver { } // Load and instantiate the result driver + $driver = $this->load_rdriver(); + $RES = new $driver($this); - $driver = $this->load_rdriver(); - $RES = new $driver(); - $RES->conn_id = $this->conn_id; - $RES->result_id = $this->result_id; - - if ($this->dbdriver == 'oci8') - { - $RES->stmt_id = $this->stmt_id; - $RES->curs_id = NULL; - $RES->limit_used = $this->limit_used; - $this->stmt_id = FALSE; - } - - // oci8 vars must be set before calling this $RES->num_rows = $RES->num_rows(); // Is query caching enabled? If so, we'll serialize the diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 730443222..61aa56121 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -47,6 +47,12 @@ class CI_DB_result { public $num_rows = 0; public $row_data = NULL; + public function __construct(&$driver_object) + { + $this->conn_id = $driver_object->conn_id; + $this->result_id = $driver_object->result_id; + } + /** * Query result. Acts as a wrapper function for the following functions. * diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 0f69fa9ef..383b9f1a0 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -38,9 +38,18 @@ */ class CI_DB_oci8_result extends CI_DB_result { - var $stmt_id; - var $curs_id; - var $limit_used; + public $stmt_id; + public $curs_id; + public $limit_used; + + public function __construct(&$driver_object) + { + parent::__construct($driver_object); + $this->stmt_id = $driver_object->stmt_id; + $this->curs_id = $driver_object->curs_id; + $this->limit_used = $driver_object->limit_used; + $driver_object->stmt_id = FALSE; + } /** * Number of rows in the result set. -- cgit v1.2.3-24-g4f1b From d3c1ccf1fa5f4a38cfc9b8f5e3eba8bb23c83cdd Mon Sep 17 00:00:00 2001 From: Hamza Bhatti Date: Mon, 5 Mar 2012 22:58:56 +0400 Subject: Fix issue #64 Modify regular expression to be able to handle SQL bracket delimiters for column names that contain special characters or SQL keywords. Signed-off-by: Hamza Bhatti --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index eaae23f30..f648e5591 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -341,7 +341,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->_track_aliases($table); // Strip apart the condition and protect the identifiers - if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match)) + if (preg_match('/([\[\w\.]+)([\W\s]+)(.+)/', $cond, $match)) { $cond = $this->_protect_identifiers($match[1]).$match[2].$this->_protect_identifiers($match[3]); } -- cgit v1.2.3-24-g4f1b From dc8dc745557c2f256abad50d32f5aae85e996b1e Mon Sep 17 00:00:00 2001 From: SammyK Date: Mon, 5 Mar 2012 16:38:29 -0600 Subject: Fixed bug for PostgreSQL driver where setting a limit() on update() or delete() would throw a syntax error from Postgres. --- system/database/drivers/postgre/postgre_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index df0f50da5..3fdcfa79e 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -587,7 +587,7 @@ class CI_DB_postgre_driver extends CI_DB { $valstr[] = $key." = ".$val; } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + $limit = ''; $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; @@ -647,7 +647,7 @@ class CI_DB_postgre_driver extends CI_DB { $conditions .= implode("\n", $like); } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + $limit = ''; return "DELETE FROM ".$table.$conditions.$limit; } -- cgit v1.2.3-24-g4f1b From 1bf8eebec1d2eb71f4553c9ec8ae82402b869887 Mon Sep 17 00:00:00 2001 From: SammyK Date: Mon, 5 Mar 2012 16:56:06 -0600 Subject: Removed order_by() from PostgreSQL driver too. --- system/database/drivers/postgre/postgre_driver.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 3fdcfa79e..5b248e9bc 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -587,16 +587,10 @@ class CI_DB_postgre_driver extends CI_DB { $valstr[] = $key." = ".$val; } - $limit = ''; - - $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; - $sql .= $orderby.$limit; - return $sql; } @@ -647,9 +641,7 @@ class CI_DB_postgre_driver extends CI_DB { $conditions .= implode("\n", $like); } - $limit = ''; - - return "DELETE FROM ".$table.$conditions.$limit; + return "DELETE FROM ".$table.$conditions; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 9c68c3173c84041b1ee77929e540a4a4382edeee Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 10:34:58 +0200 Subject: Fix issue #1125 ... for real --- system/database/drivers/odbc/odbc_result.php | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index 2d5b50a8d..de2c58cb9 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -280,6 +280,41 @@ class CI_DB_odbc_result extends CI_DB_result { return $this->result_array; } + // -------------------------------------------------------------------- + + /** + * Query result. Object version. + * + * @return array + */ + public function result_object() + { + if (count($this->result_object) > 0) + { + return $this->result_object; + } + elseif (($c = count($this->result_array)) > 0) + { + for ($i = 0; $i < $c; $i++) + { + $this->result_object[$i] = (object) $this->result_array[$i]; + } + } + elseif ($this->result_id === FALSE) + { + return array(); + } + else + { + while ($row = $this->_fetch_object()) + { + $this->result_object[] = $row; + } + } + + return $this->result_object; + } + } /* End of file odbc_result.php */ -- cgit v1.2.3-24-g4f1b From 6b83123dce4a78e06f6eedc7cb1b2bb78d2294f0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 11:16:57 +0200 Subject: Fixed a bug in CI_Session::_unserialize() --- system/libraries/Session.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index dd50a91e1..104b88810 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -454,7 +454,7 @@ class CI_Session { */ public function userdata($item) { - return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; + return isset($this->userdata[$item]) ? $this->userdata[$item] : FALSE; } // -------------------------------------------------------------------- @@ -729,7 +729,7 @@ class CI_Session { */ protected function _unserialize($data) { - $data = @unserialize(strip_slashes($data)); + $data = @unserialize(strip_slashes(trim($data))); if (is_array($data)) { @@ -737,9 +737,11 @@ class CI_Session { return $data; } - return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data; + return is_string($data) ? str_replace('{{slash}}', '\\', $data) : $data; } + // -------------------------------------------------------------------- + /** * Unescape slashes * @@ -779,7 +781,7 @@ class CI_Session { { $expire = $this->now - $this->sess_expiration; - $this->CI->db->where("last_activity < {$expire}"); + $this->CI->db->where('last_activity < '.$expire); $this->CI->db->delete($this->sess_table_name); log_message('debug', 'Session garbage collection performed.'); -- cgit v1.2.3-24-g4f1b From 883f80f7ed758f384847af3db0082f9fb6e525ee Mon Sep 17 00:00:00 2001 From: JonoB Date: Mon, 5 Mar 2012 09:51:27 +0000 Subject: Removed reset_validation() method from run() method --- system/libraries/Form_validation.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index eb6031697..cdb3d3d62 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -165,6 +165,10 @@ class CI_Form_validation { * * If an array is set through this method, then this array will * be used instead of the $_POST array + * + * Note that if you are validating multiple arrays, then the + * reset_validation() function should be called after validating + * each array due to the limitations of CI's singleton * * @param array $data * @return void @@ -324,9 +328,6 @@ class CI_Form_validation { return FALSE; } - // Clear any previous validation data - $this->_reset_validation(); - // Does the _field_data array containing the validation rules exist? // If not, we look to see if they were assigned via a config file if (count($this->_field_data) === 0) @@ -1352,7 +1353,7 @@ class CI_Form_validation { * * @return void */ - protected function _reset_validation() + public function reset_validation() { $this->_field_data = array(); $this->_config_rules = array(); -- cgit v1.2.3-24-g4f1b From f5e8e1c61e4ed82db42d82d01c4e52b767effa78 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 13:11:27 +0200 Subject: Changed rewrite_short_tags to have no effect on PHP 5.4 --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Loader.php b/system/core/Loader.php index 12daaa928..20cf7ef33 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -833,7 +833,7 @@ class CI_Loader { // If the PHP installation does not support short tags we'll // do a little string replacement, changing the short tags // to standard PHP echo statements. - if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE) + if ( ! is_php('5.4') && (bool) @ini_get('short_open_tag') === FALSE && config_item('rewrite_short_tags') == TRUE) { echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace(' Date: Tue, 6 Mar 2012 07:38:00 -0500 Subject: Added visibility keywords to DB_driver methods --- system/database/DB_driver.php | 108 +++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 70 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a61450d4c..71cf86306 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -83,7 +83,7 @@ class CI_DB_driver { * * @param array */ - function __construct($params) + public function __construct($params) { if (is_array($params)) { @@ -208,7 +208,7 @@ class CI_DB_driver { * @access public * @return string */ - function platform() + public function platform() { return $this->dbdriver; } @@ -268,7 +268,7 @@ class CI_DB_driver { * @param array An array of binding data * @return mixed */ - function query($sql, $binds = FALSE, $return_object = TRUE) + public function query($sql, $binds = FALSE, $return_object = TRUE) { if ($sql == '') { @@ -425,10 +425,9 @@ class CI_DB_driver { /** * Load the result drivers * - * @access public * @return string the name of the result class */ - function load_rdriver() + public function load_rdriver() { $driver = 'CI_DB_'.$this->dbdriver.'_result'; @@ -449,11 +448,10 @@ class CI_DB_driver { * we only use it when running transaction commands since they do * not require all the features of the main query() function. * - * @access public * @param string the sql query * @return mixed */ - function simple_query($sql) + public function simple_query($sql) { if ( ! $this->conn_id) { @@ -469,10 +467,9 @@ class CI_DB_driver { * Disable Transactions * This permits transactions to be disabled at run-time. * - * @access public * @return void */ - function trans_off() + public function trans_off() { $this->trans_enabled = FALSE; } @@ -486,10 +483,9 @@ class CI_DB_driver { * If strict mode is disabled, each group is treated autonomously, meaning * a failure of one group will not affect any others * - * @access public * @return void */ - function trans_strict($mode = TRUE) + public function trans_strict($mode = TRUE) { $this->trans_strict = is_bool($mode) ? $mode : TRUE; } @@ -499,10 +495,9 @@ class CI_DB_driver { /** * Start Transaction * - * @access public * @return void */ - function trans_start($test_mode = FALSE) + public function trans_start($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -525,10 +520,9 @@ class CI_DB_driver { /** * Complete Transaction * - * @access public * @return bool */ - function trans_complete() + public function trans_complete() { if ( ! $this->trans_enabled) { @@ -572,10 +566,9 @@ class CI_DB_driver { /** * Lets you retrieve the transaction flag to determine if it has failed * - * @access public * @return bool */ - function trans_status() + public function trans_status() { return $this->_trans_status; } @@ -585,12 +578,11 @@ class CI_DB_driver { /** * Compile Bindings * - * @access public * @param string the sql statement * @param array an array of bind data * @return string */ - function compile_binds($sql, $binds) + public function compile_binds($sql, $binds) { if (strpos($sql, $this->bind_marker) === FALSE) { @@ -641,11 +633,10 @@ class CI_DB_driver { /** * Calculate the aggregate query elapsed time * - * @access public * @param integer The number of decimal places * @return integer */ - function elapsed_time($decimals = 6) + public function elapsed_time($decimals = 6) { return number_format($this->benchmark, $decimals); } @@ -655,10 +646,9 @@ class CI_DB_driver { /** * Returns the total number of queries * - * @access public * @return integer */ - function total_queries() + public function total_queries() { return $this->query_count; } @@ -668,10 +658,9 @@ class CI_DB_driver { /** * Returns the last query that was executed * - * @access public * @return void */ - function last_query() + public function last_query() { return end($this->queries); } @@ -684,11 +673,10 @@ class CI_DB_driver { * Escapes data based on type * Sets boolean and null types * - * @access public * @param string * @return mixed */ - function escape($str) + public function escape($str) { if (is_string($str)) { @@ -714,11 +702,10 @@ class CI_DB_driver { * Calls the individual driver for platform * specific escaping for LIKE conditions * - * @access public * @param string * @return mixed */ - function escape_like_str($str) + public function escape_like_str($str) { return $this->escape_str($str, TRUE); } @@ -731,11 +718,10 @@ class CI_DB_driver { * Retrieves the primary key. It assumes that the row in the first * position is the primary key * - * @access public * @param string the table name * @return string */ - function primary($table = '') + public function primary($table = '') { $fields = $this->list_fields($table); @@ -752,10 +738,9 @@ class CI_DB_driver { /** * Returns an array of table names * - * @access public * @return array */ - function list_tables($constrain_by_prefix = FALSE) + public function list_tables($constrain_by_prefix = FALSE) { // Is there a cached result? if (isset($this->data_cache['table_names'])) @@ -801,10 +786,10 @@ class CI_DB_driver { /** * Determine if a particular table exists - * @access public + * * @return boolean */ - function table_exists($table_name) + public function table_exists($table_name) { return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE; } @@ -814,11 +799,10 @@ class CI_DB_driver { /** * Fetch MySQL Field Names * - * @access public * @param string the table name * @return array */ - function list_fields($table = '') + public function list_fields($table = '') { // Is there a cached result? if (isset($this->data_cache['field_names'][$table])) @@ -867,12 +851,12 @@ class CI_DB_driver { /** * Determine if a particular field exists - * @access public + * * @param string * @param string * @return boolean */ - function field_exists($field_name, $table_name) + public function field_exists($field_name, $table_name) { return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE; } @@ -882,11 +866,10 @@ class CI_DB_driver { /** * Returns an object with field data * - * @access public * @param string the table name * @return object */ - function field_data($table = '') + public function field_data($table = '') { if ($table == '') { @@ -907,12 +890,11 @@ class CI_DB_driver { /** * Generate an insert string * - * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @return string */ - function insert_string($table, $data) + public function insert_string($table, $data) { $fields = array(); $values = array(); @@ -931,13 +913,12 @@ class CI_DB_driver { /** * Generate an update string * - * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @param mixed the "where" statement * @return string */ - function update_string($table, $data, $where) + public function update_string($table, $data, $where) { if ($where == '') { @@ -984,11 +965,10 @@ class CI_DB_driver { /** * Tests whether the string has an SQL operator * - * @access private * @param string * @return bool */ - function _has_operator($str) + protected function _has_operator($str) { $str = trim($str); if ( ! preg_match("/(\s|<|>|!|=|is null|is not null)/i", $str)) @@ -1004,12 +984,11 @@ class CI_DB_driver { /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * - * @access public * @param string the function name * @param mixed any parameters needed by the function * @return mixed */ - function call_function($function) + public function call_function($function) { $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_'; @@ -1046,11 +1025,10 @@ class CI_DB_driver { /** * Set Cache Directory Path * - * @access public * @param string the path to the cache directory * @return void */ - function cache_set_path($path = '') + public function cache_set_path($path = '') { $this->cachedir = $path; } @@ -1060,10 +1038,9 @@ class CI_DB_driver { /** * Enable Query Caching * - * @access public * @return void */ - function cache_on() + public function cache_on() { $this->cache_on = TRUE; return TRUE; @@ -1074,10 +1051,9 @@ class CI_DB_driver { /** * Disable Query Caching * - * @access public * @return void */ - function cache_off() + public function cache_off() { $this->cache_on = FALSE; return FALSE; @@ -1089,10 +1065,9 @@ class CI_DB_driver { /** * Delete the cache files associated with a particular URI * - * @access public * @return void */ - function cache_delete($segment_one = '', $segment_two = '') + public function cache_delete($segment_one = '', $segment_two = '') { if ( ! $this->_cache_init()) { @@ -1106,10 +1081,9 @@ class CI_DB_driver { /** * Delete All cache files * - * @access public * @return void */ - function cache_delete_all() + public function cache_delete_all() { if ( ! $this->_cache_init()) { @@ -1124,10 +1098,9 @@ class CI_DB_driver { /** * Initialize the Cache Class * - * @access private * @return void */ - function _cache_init() + protected function _cache_init() { if (is_object($this->CACHE) AND class_exists('CI_DB_Cache')) { @@ -1151,10 +1124,9 @@ class CI_DB_driver { /** * Close DB Connection * - * @access public * @return void */ - function close() + public function close() { if (is_resource($this->conn_id) OR is_object($this->conn_id)) { @@ -1168,13 +1140,12 @@ class CI_DB_driver { /** * Display an error message * - * @access public * @param string the error message * @param string any "swap" values * @param boolean whether to localize the message * @return string sends the application/error_db.php template */ - function display_error($error = '', $swap = '', $native = FALSE) + public function display_error($error = '', $swap = '', $native = FALSE) { $LANG =& load_class('Lang', 'core'); $LANG->load('db'); @@ -1220,11 +1191,10 @@ class CI_DB_driver { * * This function adds backticks if appropriate based on db type * - * @access private * @param mixed the item to escape * @return mixed the item with backticks */ - function protect_identifiers($item, $prefix_single = FALSE) + protected function protect_identifiers($item, $prefix_single = FALSE) { return $this->_protect_identifiers($item, $prefix_single); } @@ -1251,14 +1221,13 @@ class CI_DB_driver { * insert the table prefix (if it exists) in the proper position, and escape only * the correct identifiers. * - * @access private * @param string * @param bool * @param mixed * @param bool * @return string */ - function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) + protected function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) { if ( ! is_bool($protect_identifiers)) { @@ -1410,7 +1379,6 @@ class CI_DB_driver { * * This function is used extensively by every db driver. * - * @access private * @return void */ protected function _reset_select() -- cgit v1.2.3-24-g4f1b From 7869559a56f0974c1bcf42d6ebd13bd872b3421c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 6 Mar 2012 08:02:49 -0500 Subject: Made protect_identifiers public --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 71cf86306..7bb5dfabe 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1194,7 +1194,7 @@ class CI_DB_driver { * @param mixed the item to escape * @return mixed the item with backticks */ - protected function protect_identifiers($item, $prefix_single = FALSE) + public function protect_identifiers($item, $prefix_single = FALSE) { return $this->_protect_identifiers($item, $prefix_single); } -- cgit v1.2.3-24-g4f1b From a4c33fe97910c92f9bc53570722b5b81108e64d7 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 6 Mar 2012 08:31:02 -0500 Subject: Made _protect_identifiers public --- system/database/DB_driver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 7bb5dfabe..3977b35c1 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1221,13 +1221,16 @@ class CI_DB_driver { * insert the table prefix (if it exists) in the proper position, and escape only * the correct identifiers. * + * While this should be protected, the db forge drivers apparently use this instead + * of the unprefixed function + * * @param string * @param bool * @param mixed * @param bool * @return string */ - protected function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) + public function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) { if ( ! is_bool($protect_identifiers)) { -- cgit v1.2.3-24-g4f1b From 032e7ea646b953a8f4d28327d7f487de2ffa7288 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 19:48:35 +0200 Subject: Resolve _protect_identifiers()/protect_identifiers() usage issues --- system/database/DB_active_rec.php | 62 ++++++++++------------ system/database/DB_driver.php | 34 +++--------- system/database/drivers/cubrid/cubrid_driver.php | 5 +- system/database/drivers/cubrid/cubrid_forge.php | 30 +++++------ .../drivers/interbase/interbase_driver.php | 3 +- system/database/drivers/mssql/mssql_driver.php | 3 +- system/database/drivers/mssql/mssql_forge.php | 17 +++--- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/mysql/mysql_forge.php | 8 +-- system/database/drivers/mysqli/mysqli_driver.php | 6 +-- system/database/drivers/mysqli/mysqli_forge.php | 2 +- system/database/drivers/oci8/oci8_driver.php | 3 +- system/database/drivers/oci8/oci8_forge.php | 8 ++- system/database/drivers/odbc/odbc_driver.php | 2 +- system/database/drivers/odbc/odbc_forge.php | 18 +++---- system/database/drivers/pdo/pdo_driver.php | 3 +- system/database/drivers/pdo/pdo_forge.php | 17 +++--- system/database/drivers/postgre/postgre_driver.php | 3 +- system/database/drivers/postgre/postgre_forge.php | 21 ++++---- system/database/drivers/sqlite/sqlite_driver.php | 3 +- system/database/drivers/sqlite/sqlite_forge.php | 16 +++--- system/database/drivers/sqlsrv/sqlsrv_forge.php | 19 ++++--- 22 files changed, 123 insertions(+), 162 deletions(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index f648e5591..de8cfc1ca 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -212,7 +212,7 @@ class CI_DB_active_record extends CI_DB_driver { $alias = $this->_create_alias_from_table(trim($select)); } - $sql = $this->_protect_identifiers($type.'('.trim($select).')').' AS '.$this->_protect_identifiers(trim($alias)); + $sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->protect_identifiers(trim($alias)); $this->ar_select[] = $sql; if ($this->ar_caching === TRUE) @@ -279,7 +279,7 @@ class CI_DB_active_record extends CI_DB_driver { { $v = trim($v); $this->_track_aliases($v); - $v = $this->ar_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE); + $v = $this->ar_from[] = $this->protect_identifiers($v, TRUE, NULL, FALSE); if ($this->ar_caching === TRUE) { @@ -295,7 +295,7 @@ class CI_DB_active_record extends CI_DB_driver { // Extract any aliases that might exist. We use this information // in the _protect_identifiers to know whether to add a table prefix $this->_track_aliases($val); - $this->ar_from[] = $val = $this->_protect_identifiers($val, TRUE, NULL, FALSE); + $this->ar_from[] = $val = $this->protect_identifiers($val, TRUE, NULL, FALSE); if ($this->ar_caching === TRUE) { @@ -343,11 +343,11 @@ class CI_DB_active_record extends CI_DB_driver { // Strip apart the condition and protect the identifiers if (preg_match('/([\[\w\.]+)([\W\s]+)(.+)/', $cond, $match)) { - $cond = $this->_protect_identifiers($match[1]).$match[2].$this->_protect_identifiers($match[3]); + $cond = $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); } // Assemble the JOIN statement - $this->ar_join[] = $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond; + $this->ar_join[] = $join = $type.'JOIN '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond; if ($this->ar_caching === TRUE) { @@ -433,7 +433,7 @@ class CI_DB_active_record extends CI_DB_driver { { if ($escape === TRUE) { - $k = $this->_protect_identifiers($k, FALSE, $escape); + $k = $this->protect_identifiers($k, FALSE, $escape); $v = ' '.$this->escape($v); } @@ -444,7 +444,7 @@ class CI_DB_active_record extends CI_DB_driver { } else { - $k = $this->_protect_identifiers($k, FALSE, $escape); + $k = $this->protect_identifiers($k, FALSE, $escape); } $this->ar_where[] = $prefix.$k.$v; @@ -562,7 +562,7 @@ class CI_DB_active_record extends CI_DB_driver { } $prefix = (count($this->ar_where) === 0) ? '' : $type; - $this->ar_where[] = $where_in = $prefix.$this->_protect_identifiers($key).$not.' IN ('.implode(', ', $this->ar_wherein).') '; + $this->ar_where[] = $where_in = $prefix.$this->protect_identifiers($key).$not.' IN ('.implode(', ', $this->ar_wherein).') '; if ($this->ar_caching === TRUE) { @@ -666,7 +666,7 @@ class CI_DB_active_record extends CI_DB_driver { foreach ($field as $k => $v) { - $k = $this->_protect_identifiers($k); + $k = $this->protect_identifiers($k); $prefix = (count($this->ar_like) === 0) ? '' : $type; $v = $this->escape_like_str($v); @@ -827,7 +827,7 @@ class CI_DB_active_record extends CI_DB_driver { if ($val != '') { - $this->ar_groupby[] = $val = $this->_protect_identifiers($val); + $this->ar_groupby[] = $val = $this->protect_identifiers($val); if ($this->ar_caching === TRUE) { @@ -896,7 +896,7 @@ class CI_DB_active_record extends CI_DB_driver { if ($escape === TRUE) { - $k = $this->_protect_identifiers($k); + $k = $this->protect_identifiers($k); } if ( ! $this->_has_operator($k)) @@ -951,7 +951,7 @@ class CI_DB_active_record extends CI_DB_driver { $part = trim($part); if ( ! in_array($part, $this->ar_aliased_tables)) { - $part = $this->_protect_identifiers(trim($part)); + $part = $this->protect_identifiers(trim($part)); } $temp[] = $part; @@ -963,7 +963,7 @@ class CI_DB_active_record extends CI_DB_driver { { if ($escape === TRUE) { - $orderby = $this->_protect_identifiers($orderby); + $orderby = $this->protect_identifiers($orderby); } } @@ -1036,11 +1036,11 @@ class CI_DB_active_record extends CI_DB_driver { { if ($escape === FALSE) { - $this->ar_set[$this->_protect_identifiers($k)] = $v; + $this->ar_set[$this->protect_identifiers($k)] = $v; } else { - $this->ar_set[$this->_protect_identifiers($k, FALSE, TRUE)] = $this->escape($v); + $this->ar_set[$this->protect_identifiers($k, FALSE, TRUE)] = $this->escape($v); } } @@ -1125,7 +1125,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->from($table); } - $result = $this->query($this->_compile_select($this->_count_string.$this->_protect_identifiers('numrows'))); + $result = $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows'))); $this->_reset_select(); if ($result->num_rows() === 0) @@ -1211,7 +1211,7 @@ class CI_DB_active_record extends CI_DB_driver { // Batch this baby for ($i = 0, $total = count($this->ar_set); $i < $total; $i += 100) { - $this->query($this->_insert_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100))); + $this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100))); } $this->_reset_write(); @@ -1269,7 +1269,7 @@ class CI_DB_active_record extends CI_DB_driver { foreach ($keys as $k) { - $this->ar_keys[] = $this->_protect_identifiers($k); + $this->ar_keys[] = $this->protect_identifiers($k); } return $this; @@ -1295,9 +1295,7 @@ class CI_DB_active_record extends CI_DB_driver { } $sql = $this->_insert( - $this->_protect_identifiers( - $this->ar_from[0], TRUE, NULL, FALSE - ), + $this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set) ); @@ -1335,9 +1333,7 @@ class CI_DB_active_record extends CI_DB_driver { } $sql = $this->_insert( - $this->_protect_identifiers( - $this->ar_from[0], TRUE, NULL, FALSE - ), + $this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set) ); @@ -1414,7 +1410,7 @@ class CI_DB_active_record extends CI_DB_driver { $table = $this->ar_from[0]; } - $sql = $this->_replace($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set)); + $sql = $this->_replace($this->protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set)); $this->_reset_write(); return $this->query($sql); } @@ -1441,7 +1437,7 @@ class CI_DB_active_record extends CI_DB_driver { return FALSE; } - $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit); + $sql = $this->_update($this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit); if ($reset === TRUE) { @@ -1488,7 +1484,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->limit($limit); } - $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, $this->ar_like); + $sql = $this->_update($this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, $this->ar_like); $this->_reset_write(); return $this->query($sql); } @@ -1573,7 +1569,7 @@ class CI_DB_active_record extends CI_DB_driver { // Batch this baby for ($i = 0, $total = count($this->ar_set); $i < $total; $i += 100) { - $this->query($this->_update_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->_protect_identifiers($index), $this->ar_where)); + $this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->protect_identifiers($index), $this->ar_where)); } $this->_reset_write(); @@ -1614,7 +1610,7 @@ class CI_DB_active_record extends CI_DB_driver { $not[] = $k.'-'.$v; } - $clean[$this->_protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2); + $clean[$this->protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2); } if ($index_set == FALSE) @@ -1651,7 +1647,7 @@ class CI_DB_active_record extends CI_DB_driver { } else { - $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE); + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); } $sql = $this->_delete($table); @@ -1684,7 +1680,7 @@ class CI_DB_active_record extends CI_DB_driver { } else { - $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE); + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); } $sql = $this->_truncate($table); @@ -1751,7 +1747,7 @@ class CI_DB_active_record extends CI_DB_driver { } else { - $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE); + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); } if ($where != '') @@ -1894,7 +1890,7 @@ class CI_DB_active_record extends CI_DB_driver { foreach ($this->ar_select as $key => $val) { $no_escape = isset($this->ar_no_escape[$key]) ? $this->ar_no_escape[$key] : NULL; - $this->ar_select[$key] = $this->_protect_identifiers($val, FALSE, $no_escape); + $this->ar_select[$key] = $this->protect_identifiers($val, FALSE, $no_escape); } $sql .= implode(', ', $this->ar_select); diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 3977b35c1..597f5e9a5 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -791,7 +791,7 @@ class CI_DB_driver { */ public function table_exists($table_name) { - return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE; + return in_array($this->protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables()); } // -------------------------------------------------------------------- @@ -880,7 +880,7 @@ class CI_DB_driver { return FALSE; } - $query = $this->query($this->_field_data($this->_protect_identifiers($table, TRUE, NULL, FALSE))); + $query = $this->query($this->_field_data($this->protect_identifiers($table, TRUE, NULL, FALSE))); return $query->field_data(); } @@ -905,7 +905,7 @@ class CI_DB_driver { $values[] = $this->escape($val); } - return $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $values); + return $this->_insert($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $values); } // -------------------------------------------------------------------- @@ -928,7 +928,7 @@ class CI_DB_driver { $fields = array(); foreach ($data as $key => $val) { - $fields[$this->_protect_identifiers($key)] = $this->escape($val); + $fields[$this->protect_identifiers($key)] = $this->escape($val); } if ( ! is_array($where)) @@ -941,7 +941,7 @@ class CI_DB_driver { foreach ($where as $key => $val) { $prefix = (count($dest) == 0) ? '' : ' AND '; - $key = $this->_protect_identifiers($key); + $key = $this->protect_identifiers($key); if ($val !== '') { @@ -957,7 +957,7 @@ class CI_DB_driver { } } - return $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest); + return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest); } // -------------------------------------------------------------------- @@ -1186,21 +1186,6 @@ class CI_DB_driver { // -------------------------------------------------------------------- - /** - * Protect Identifiers - * - * This function adds backticks if appropriate based on db type - * - * @param mixed the item to escape - * @return mixed the item with backticks - */ - public function protect_identifiers($item, $prefix_single = FALSE) - { - return $this->_protect_identifiers($item, $prefix_single); - } - - // -------------------------------------------------------------------- - /** * Protect Identifiers * @@ -1221,16 +1206,13 @@ class CI_DB_driver { * insert the table prefix (if it exists) in the proper position, and escape only * the correct identifiers. * - * While this should be protected, the db forge drivers apparently use this instead - * of the unprefixed function - * * @param string * @param bool * @param mixed * @param bool * @return string */ - public function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) + public function protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) { if ( ! is_bool($protect_identifiers)) { @@ -1243,7 +1225,7 @@ class CI_DB_driver { foreach ($item as $k => $v) { - $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v); + $escaped_array[$this->protect_identifiers($k)] = $this->protect_identifiers($v); } return $escaped_array; diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index afdaef351..3c0850ad3 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -378,9 +378,8 @@ class CI_DB_cubrid_driver extends CI_DB { { return 0; } - - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { return 0; @@ -427,7 +426,7 @@ class CI_DB_cubrid_driver extends CI_DB { */ function _list_columns($table = '') { - return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE); + return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 85e740057..76002cb38 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -93,11 +93,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t\"" . $this->db->_protect_identifiers($field) . "\""; + $sql .= "\n\t\"".$this->db->protect_identifiers($field).'"'; if (array_key_exists('NAME', $attributes)) { - $sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' '; + $sql .= ' '.$this->db->protect_identifiers($attributes['NAME']).' '; } if (array_key_exists('TYPE', $attributes)) @@ -197,10 +197,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge { // If there is a PK defined if (count($primary_keys) > 0) { - $key_name = "pk_" . $table . "_" . - $this->db->_protect_identifiers(implode('_', $primary_keys)); - - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $key_name = 'pk_'.$table.'_'.$this->db->protect_identifiers(implode('_', $primary_keys)); + + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")"; } @@ -210,15 +209,15 @@ class CI_DB_cubrid_forge extends CI_DB_forge { { if (is_array($key)) { - $key_name = $this->db->_protect_identifiers(implode('_', $key)); - $key = $this->db->_protect_identifiers($key); + $key_name = $this->db->protect_identifiers(implode('_', $key)); + $key = $this->db->protect_identifiers($key); } else { - $key_name = $this->db->_protect_identifiers($key); + $key_name = $this->db->protect_identifiers($key); $key = array($key_name); } - + $sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")"; } } @@ -258,19 +257,19 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $fields, $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type "; + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; // DROP has everything it needs now. if ($alter_type == 'DROP') { - return $sql.$this->db->_protect_identifiers($fields); + return $sql.$this->db->protect_identifiers($fields); } $sql .= $this->_process_fields($fields); if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -290,11 +289,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ function _rename_table($table_name, $new_table_name) { - $sql = 'RENAME TABLE '.$this->db->_protect_identifiers($table_name)." AS ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name); } } /* End of file cubrid_forge.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index f4bd9e271..bacb6688c 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -320,8 +320,7 @@ class CI_DB_interbase_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - + $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { return 0; diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 147c63483..39b84f9c6 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -365,8 +365,7 @@ class CI_DB_mssql_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - + $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { return 0; diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index dd8aa3448..ec97805ac 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -113,7 +113,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $sql .= ' '.$attributes['TYPE']; @@ -156,7 +156,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } @@ -166,11 +166,11 @@ class CI_DB_mssql_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; @@ -202,7 +202,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type == 'DROP') @@ -228,7 +228,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -250,11 +250,10 @@ class CI_DB_mssql_forge extends CI_DB_forge { function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } /* End of file mssql_forge.php */ -/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/mssql/mssql_forge.php */ diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7fd08a6ed..cd1763751 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -416,7 +416,7 @@ class CI_DB_mysql_driver extends CI_DB { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } - $query = $this->query('DESCRIBE '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query('DESCRIBE '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); $query = $query->result_object(); $retval = array(); diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 0f251b086..a907b20fa 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -151,7 +151,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $key_name = $this->db->_protect_identifiers(implode('_', $primary_keys)); + $key_name = $this->db->protect_identifiers(implode('_', $primary_keys)); $sql .= ",\n\tPRIMARY KEY ".$key_name.' ('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; } @@ -161,12 +161,12 @@ class CI_DB_mysql_forge extends CI_DB_forge { { if (is_array($key)) { - $key_name = $this->db->_protect_identifiers(implode('_', $key)); - $key = $this->db->_protect_identifiers($key); + $key_name = $this->db->protect_identifiers(implode('_', $key)); + $key = $this->db->protect_identifiers($key); } else { - $key_name = $this->db->_protect_identifiers($key); + $key_name = $this->db->protect_identifiers($key); $key = array($key_name); } diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 25b6ceca1..d06119a13 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -353,7 +353,7 @@ class CI_DB_mysqli_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string.$this->_protect_identifiers('numrows').' FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { return 0; @@ -399,7 +399,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ protected function _list_columns($table = '') { - return 'SHOW COLUMNS FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE); + return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); } // -------------------------------------------------------------------- @@ -417,7 +417,7 @@ class CI_DB_mysqli_driver extends CI_DB { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } - $query = $this->query('DESCRIBE '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query('DESCRIBE '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); $query = $query->result_object(); $retval = array(); diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 7de036127..744525f02 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -183,7 +183,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { */ public function _alter_table($alter_type, $table, $fields, $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table).' '.$alter_type.' '; + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; // DROP has everything it needs now. if ($alter_type === 'DROP') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 35cafff6c..8db6c1286 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -458,8 +458,7 @@ class CI_DB_oci8_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - + $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query == FALSE) { return 0; diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 0aa119907..48f98d022 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -172,7 +172,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type == 'DROP') @@ -198,7 +198,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -219,11 +219,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { */ function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } - } /* End of file oci8_forge.php */ diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index a6e08cf2f..2575f431d 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -313,7 +313,7 @@ class CI_DB_odbc_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query($this->_count_string . $this->protect_identifiers('numrows') . " FROM " . $this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index e0ec687c8..51addf03d 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -112,7 +112,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $sql .= ' '.$attributes['TYPE']; @@ -155,7 +155,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } @@ -165,11 +165,11 @@ class CI_DB_odbc_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; @@ -219,7 +219,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type == 'DROP') @@ -245,7 +245,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -267,12 +267,10 @@ class CI_DB_odbc_forge extends CI_DB_forge { */ function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } - } /* End of file odbc_forge.php */ -/* Location: ./system/database/drivers/odbc/odbc_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/odbc/odbc_forge.php */ diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 8fdfd58fb..eadb78ffe 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -530,8 +530,7 @@ class CI_DB_pdo_driver extends CI_DB { return 0; } - $sql = $this->_count_string.$this->_protect_identifiers('numrows').' FROM '; - $sql .= $this->_protect_identifiers($table, TRUE, NULL, FALSE); + $sql = $this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); $query = $this->query($sql); if ($query->num_rows() == 0) diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 478b2dbfb..b4ddca5fe 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -113,7 +113,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { $attributes = array_change_key_case($attributes, CASE_UPPER); $numeric = array('SERIAL', 'INTEGER'); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $sql .= ' '.$attributes['TYPE']; @@ -160,7 +160,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } @@ -170,11 +170,11 @@ class CI_DB_pdo_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; @@ -224,7 +224,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE `'.$this->db->_protect_identifiers($table)."` $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type == 'DROP') @@ -250,7 +250,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -272,11 +272,10 @@ class CI_DB_pdo_forge extends CI_DB_forge { */ function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } /* End of file pdo_forge.php */ -/* Location: ./system/database/drivers/pdo/pdo_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/pdo/pdo_forge.php */ diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 5b248e9bc..6feec7353 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -383,8 +383,7 @@ class CI_DB_postgre_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - + $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { return 0; diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 756fd347a..4a7348aa6 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -88,7 +88,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $is_unsigned = (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE); @@ -203,10 +203,10 @@ class CI_DB_postgre_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - // Something seems to break when passing an array to _protect_identifiers() + // Something seems to break when passing an array to protect_identifiers() foreach ($primary_keys as $index => $key) { - $primary_keys[$index] = $this->db->_protect_identifiers($key); + $primary_keys[$index] = $this->db->protect_identifiers($key); } $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; @@ -220,11 +220,11 @@ class CI_DB_postgre_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } foreach ($key as $field) @@ -267,19 +267,19 @@ class CI_DB_postgre_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $fields, $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type "; + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; // DROP has everything it needs now. if ($alter_type == 'DROP') { - return $sql.$this->db->_protect_identifiers($fields); + return $sql.$this->db->protect_identifiers($fields); } $sql .= $this->_process_fields($fields); if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -299,10 +299,9 @@ class CI_DB_postgre_forge extends CI_DB_forge { */ function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } /* End of file postgre_forge.php */ -/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/postgre/postgre_forge.php */ diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 3eaec949c..91598ab0f 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -343,8 +343,7 @@ class CI_DB_sqlite_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - + $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { return 0; diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index fd0f3eb98..4f379d96f 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -110,7 +110,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $sql .= ' '.$attributes['TYPE']; @@ -153,7 +153,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } @@ -163,11 +163,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")"; @@ -218,7 +218,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type == 'DROP') @@ -247,7 +247,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -268,9 +268,9 @@ class CI_DB_sqlite_forge extends CI_DB_forge { */ function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } + } /* End of file sqlite_forge.php */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 2a7766927..152192241 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -113,7 +113,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $sql .= ' '.$attributes['TYPE']; @@ -156,7 +156,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } @@ -166,11 +166,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; @@ -202,7 +202,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. if ($alter_type == 'DROP') @@ -228,7 +228,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } return $sql; @@ -250,11 +250,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } -/* End of file mssql_forge.php */ -/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file +/* End of file sqlsrv_forge.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ -- cgit v1.2.3-24-g4f1b From d1add43b7972f89a89371bb090aea793c72ed7bc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 20:26:01 +0200 Subject: Property visibility declarations for CI_DB_driver --- system/database/DB_driver.php | 75 ++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 40 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 597f5e9a5..7b8d0870f 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -42,47 +42,42 @@ */ class CI_DB_driver { - var $username; - var $password; - var $hostname; - var $database; - var $dbdriver = 'mysql'; - var $dbprefix = ''; - var $char_set = 'utf8'; - var $dbcollat = 'utf8_general_ci'; - var $autoinit = TRUE; // Whether to automatically initialize the DB - var $swap_pre = ''; - var $port = ''; - var $pconnect = FALSE; - var $conn_id = FALSE; - var $result_id = FALSE; - var $db_debug = FALSE; - var $benchmark = 0; - var $query_count = 0; - var $bind_marker = '?'; - var $save_queries = TRUE; - var $queries = array(); - var $query_times = array(); - var $data_cache = array(); - var $trans_enabled = TRUE; - var $trans_strict = TRUE; - var $_trans_depth = 0; - var $_trans_status = TRUE; // Used with transactions to determine if a rollback should occur - var $cache_on = FALSE; - var $cachedir = ''; - var $cache_autodel = FALSE; - var $CACHE; // The cache class object - - // Private variables - var $_protect_identifiers = TRUE; - var $_reserved_identifiers = array('*'); // Identifiers that should NOT be escaped + public $username; + public $password; + public $hostname; + public $database; + public $dbdriver = 'mysql'; + public $dbprefix = ''; + public $char_set = 'utf8'; + public $dbcollat = 'utf8_general_ci'; + public $autoinit = TRUE; // Whether to automatically initialize the DB + public $swap_pre = ''; + public $port = ''; + public $pconnect = FALSE; + public $conn_id = FALSE; + public $result_id = FALSE; + public $db_debug = FALSE; + public $benchmark = 0; + public $query_count = 0; + public $bind_marker = '?'; + public $save_queries = TRUE; + public $queries = array(); + public $query_times = array(); + public $data_cache = array(); + + public $trans_enabled = TRUE; + public $trans_strict = TRUE; + protected $_trans_depth = 0; + protected $_trans_status = TRUE; // Used with transactions to determine if a rollback should occur + + public $cache_on = FALSE; + public $cachedir = ''; + public $cache_autodel = FALSE; + public $CACHE; // The cache class object + + protected $_protect_identifiers = TRUE; + protected $_reserved_identifiers = array('*'); // Identifiers that should NOT be escaped - /** - * Constructor. Accepts one parameter containing the database - * connection settings. - * - * @param array - */ public function __construct($params) { if (is_array($params)) -- cgit v1.2.3-24-g4f1b From 4c20260e72a4f2aae21417121a864b34bab51496 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 20:34:52 +0200 Subject: Just some comment fixes and cleared spaces --- system/database/DB_driver.php | 60 +++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 33 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 7b8d0870f..af496aa7f 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1,13 +1,13 @@ -compile_binds($sql, $binds); } - // Is query caching enabled? If the query is a "read type" + // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists if ($this->cache_on == TRUE AND stristr($sql, 'SELECT')) @@ -439,7 +435,7 @@ class CI_DB_driver { /** * Simple Query - * This is a simplified version of the query() function. Internally + * This is a simplified version of the query() function. Internally * we only use it when running transaction commands since they do * not require all the features of the main query() function. * @@ -628,8 +624,8 @@ class CI_DB_driver { /** * Calculate the aggregate query elapsed time * - * @param integer The number of decimal places - * @return integer + * @param int The number of decimal places + * @return int */ public function elapsed_time($decimals = 6) { @@ -641,7 +637,7 @@ class CI_DB_driver { /** * Returns the total number of queries * - * @return integer + * @return int */ public function total_queries() { @@ -653,7 +649,7 @@ class CI_DB_driver { /** * Returns the last query that was executed * - * @return void + * @return string */ public function last_query() { @@ -710,7 +706,7 @@ class CI_DB_driver { /** * Primary * - * Retrieves the primary key. It assumes that the row in the first + * Retrieves the primary key. It assumes that the row in the first * position is the primary key * * @param string the table name @@ -773,7 +769,7 @@ class CI_DB_driver { } $this->data_cache['table_names'] = $retval; - + return $this->data_cache['table_names']; } @@ -782,7 +778,7 @@ class CI_DB_driver { /** * Determine if a particular table exists * - * @return boolean + * @return bool */ public function table_exists($table_name) { @@ -849,7 +845,7 @@ class CI_DB_driver { * * @param string * @param string - * @return boolean + * @return bool */ public function field_exists($field_name, $table_name) { @@ -917,7 +913,7 @@ class CI_DB_driver { { if ($where == '') { - return false; + return FALSE; } $fields = array(); @@ -1033,7 +1029,7 @@ class CI_DB_driver { /** * Enable Query Caching * - * @return void + * @return bool cache_on value */ public function cache_on() { @@ -1046,7 +1042,7 @@ class CI_DB_driver { /** * Disable Query Caching * - * @return void + * @return bool cache_on value */ public function cache_off() { @@ -1060,7 +1056,7 @@ class CI_DB_driver { /** * Delete the cache files associated with a particular URI * - * @return void + * @return bool */ public function cache_delete($segment_one = '', $segment_two = '') { @@ -1076,7 +1072,7 @@ class CI_DB_driver { /** * Delete All cache files * - * @return void + * @return bool */ public function cache_delete_all() { @@ -1093,7 +1089,7 @@ class CI_DB_driver { /** * Initialize the Cache Class * - * @return void + * @return bool */ protected function _cache_init() { @@ -1137,7 +1133,7 @@ class CI_DB_driver { * * @param string the error message * @param string any "swap" values - * @param boolean whether to localize the message + * @param bool whether to localize the message * @return string sends the application/error_db.php template */ public function display_error($error = '', $swap = '', $native = FALSE) @@ -1188,7 +1184,7 @@ class CI_DB_driver { * a couple functions in this class. * It takes a column or table name (optionally with an alias) and inserts * the table prefix onto it. Some logic is necessary in order to deal with - * column names that include the path. Consider a query like this: + * column names that include the path. Consider a query like this: * * SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table * @@ -1217,7 +1213,6 @@ class CI_DB_driver { if (is_array($item)) { $escaped_array = array(); - foreach ($item as $k => $v) { $escaped_array[$this->protect_identifiers($k)] = $this->protect_identifiers($v); @@ -1240,7 +1235,7 @@ class CI_DB_driver { // This is basically a bug fix for queries that use MAX, MIN, etc. // If a parenthesis is found we know that we do not need to - // escape the data or add a prefix. There's probably a more graceful + // escape the data or add a prefix. There's probably a more graceful // way to deal with this, but I'm not thinking of it -- Rick if (strpos($item, '(') !== FALSE) { @@ -1255,7 +1250,7 @@ class CI_DB_driver { $parts = explode('.', $item); // Does the first segment of the exploded item match - // one of the aliases previously identified? If so, + // one of the aliases previously identified? If so, // we have nothing more to do other than escape the item if (in_array($parts[0], $this->ar_aliased_tables)) { @@ -1274,7 +1269,7 @@ class CI_DB_driver { return $item.$alias; } - // Is there a table prefix defined in the config file? If not, no need to do anything + // Is there a table prefix defined in the config file? If not, no need to do anything if ($this->dbprefix != '') { // We now add the table prefix based on some logic. @@ -1328,7 +1323,7 @@ class CI_DB_driver { return $item.$alias; } - // Is there a table prefix? If not, no need to insert it + // Is there a table prefix? If not, no need to insert it if ($this->dbprefix != '') { // Verify table prefix and replace if necessary @@ -1351,7 +1346,7 @@ class CI_DB_driver { return $item.$alias; } - + // -------------------------------------------------------------------- /** @@ -1363,7 +1358,6 @@ class CI_DB_driver { */ protected function _reset_select() { - } } -- cgit v1.2.3-24-g4f1b From 5d93e13326b86344610cf13008726e40bef0a5b8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 20:36:21 +0200 Subject: Revert a comment change --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 1dc80a104..482a6c8f3 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -854,7 +854,7 @@ class CI_DB_driver { * Returns an object with field data * * @param string the table name - * @return mixed + * @return object */ public function field_data($table = '') { -- cgit v1.2.3-24-g4f1b From 738f53448fecd1a27c7f89965fbfc47b3bafdb9b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Mar 2012 20:43:40 +0200 Subject: Move dsn property from the PDO to CI_DB_driver so other DB drivers can use it without declaring it --- system/database/DB_driver.php | 1 + system/database/drivers/pdo/pdo_driver.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index af496aa7f..025441f90 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -40,6 +40,7 @@ */ class CI_DB_driver { + public $dsn; public $username; public $password; public $hostname; diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index eadb78ffe..c8732ac3c 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -59,8 +59,7 @@ class CI_DB_pdo_driver extends CI_DB { var $_count_string = "SELECT COUNT(*) AS "; var $_random_keyword; - // need to track the pdo DSN, driver and options - var $dsn; + // need to track the pdo driver and options var $pdodriver; var $options = array(); -- cgit v1.2.3-24-g4f1b From be0ca26c9006981eced5d938060ba5bad4145e3b Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 7 Mar 2012 19:09:51 +0100 Subject: added method() and is_method() --- system/core/Input.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index ee15f4013..e8e3b1d9c 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -699,6 +699,35 @@ class CI_Input { return (php_sapi_name() === 'cli' OR defined('STDIN')); } + // -------------------------------------------------------------------- + + /** + * Get Request Method + * + * Return the Request Method in lowercase + * + * @return mixed + */ + public function method() + { + return strtolower($this->server('REQUEST_METHOD')); + } + + // -------------------------------------------------------------------- + + /** + * Validate parameter against $_SERVER['REQUEST_METHOD'] + * + * Return TRUE if method equals $_SERVER['REQUEST_METHOD'], otherwise return FALSE + * + * @param string request method to match + * @return bool + */ + public function is_method($method = '') + { + return ($this->method() === strtolower($method)); + } + } /* End of file Input.php */ -- cgit v1.2.3-24-g4f1b From dc900df67972ed1c961fc3e4173db98047bdbd1b Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 7 Mar 2012 20:41:37 +0100 Subject: removed is_method --- system/core/Input.php | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index e8e3b1d9c..65de8c824 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -704,28 +704,16 @@ class CI_Input { /** * Get Request Method * - * Return the Request Method in lowercase + * Return the Request Method * + * @param bool uppercase or lowercase * @return mixed */ - public function method() + public function method($upper = TRUE) { - return strtolower($this->server('REQUEST_METHOD')); - } - - // -------------------------------------------------------------------- - - /** - * Validate parameter against $_SERVER['REQUEST_METHOD'] - * - * Return TRUE if method equals $_SERVER['REQUEST_METHOD'], otherwise return FALSE - * - * @param string request method to match - * @return bool - */ - public function is_method($method = '') - { - return ($this->method() === strtolower($method)); + return ($upper) + ? strtoupper($this->server('REQUEST_METHOD')) + : strtolower($this->server('REQUEST_METHOD')); } } -- cgit v1.2.3-24-g4f1b From 704fb1697f0db2369a9395c362c931999c8831f1 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 7 Mar 2012 20:42:33 +0100 Subject: oops --- system/core/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 65de8c824..79910890e 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -709,7 +709,7 @@ class CI_Input { * @param bool uppercase or lowercase * @return mixed */ - public function method($upper = TRUE) + public function method($upper = FALSE) { return ($upper) ? strtoupper($this->server('REQUEST_METHOD')) -- cgit v1.2.3-24-g4f1b From 7c8841f7b2fca5822e05b5d3044c748e07c800e4 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 7 Mar 2012 20:49:06 +0100 Subject: comment fix --- system/core/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 79910890e..5a4659a5a 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -707,7 +707,7 @@ class CI_Input { * Return the Request Method * * @param bool uppercase or lowercase - * @return mixed + * @return bool */ public function method($upper = FALSE) { -- cgit v1.2.3-24-g4f1b From c2659b8e91afd0af69b371c0ad92e6b1be99a5e9 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 7 Mar 2012 21:34:52 +0100 Subject: fix + style fix --- system/helpers/captcha_helper.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 668b034d4..4a48df27e 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * 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: @@ -94,16 +94,15 @@ if ( ! function_exists('create_captcha')) // Remove old images // ----------------------------------- - list($usec, $sec) = explode(" ", microtime()); - $now = ((float)$usec + (float)$sec); + $now = microtime(TRUE); $current_dir = @opendir($img_path); while ($filename = @readdir($current_dir)) { - if ($filename != "." and $filename != ".." and $filename != "index.html") + if ($filename != '.' && $filename != '..' && $filename != 'index.html') { - $name = str_replace(".jpg", "", $filename); + $name = str_replace('.jpg', '', $filename); if (($name + $expiration) < $now) { @@ -198,7 +197,7 @@ if ( ! function_exists('create_captcha')) // Write the text // ----------------------------------- - $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE; + $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext')) ? TRUE : FALSE; if ($use_font == FALSE) { -- cgit v1.2.3-24-g4f1b From 3b2c5083034675d88d9e516b5c5aca5119d6f918 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 7 Mar 2012 22:49:24 +0200 Subject: Fix issue #501 --- system/libraries/Form_validation.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index cdb3d3d62..bd8b7c216 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -65,7 +65,7 @@ class CI_Form_validation { mb_internal_encoding($this->CI->config->item('charset')); } - log_message('debug', "Form Validation Class Initialized"); + log_message('debug', 'Form Validation Class Initialized'); } // -------------------------------------------------------------------- @@ -84,7 +84,7 @@ class CI_Form_validation { { // No reason to set rules if we have no POST data // or a validation array has not been specified - if (count($_POST) === 0 && count($this->validation_data) === 0) + if ($this->CI->input->method() !== 'post' && empty($this->validation_data)) { return $this; } @@ -165,9 +165,9 @@ class CI_Form_validation { * * If an array is set through this method, then this array will * be used instead of the $_POST array - * - * Note that if you are validating multiple arrays, then the - * reset_validation() function should be called after validating + * + * Note that if you are validating multiple arrays, then the + * reset_validation() function should be called after validating * each array due to the limitations of CI's singleton * * @param array $data @@ -1156,15 +1156,14 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + /** * Equal to or Greater than * - * @access public * @param string * @return bool */ - function greater_than_equal_to($str, $min) + public function greater_than_equal_to($str, $min) { if ( ! is_numeric($str)) { @@ -1195,11 +1194,10 @@ class CI_Form_validation { /** * Equal to or Less than * - * @access public * @param string * @return bool */ - function less_than_equal_to($str, $max) + public function less_than_equal_to($str, $max) { if ( ! is_numeric($str)) { @@ -1351,7 +1349,7 @@ class CI_Form_validation { * Prevents subsequent validation routines from being affected by the * results of any previous validation routine due to the CI singleton. * - * @return void + * @return void */ public function reset_validation() { -- cgit v1.2.3-24-g4f1b From fd15423734b23ce1f10a24b6fc57f6b16a3b361b Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Wed, 7 Mar 2012 19:58:58 -0500 Subject: Fixed bug with rules not being passed to _config_delimiters or back into $this->_config_rules. --- system/libraries/Form_validation.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f2f3712d9..f3535b225 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -54,7 +54,7 @@ class CI_Form_validation { $this->CI =& get_instance(); // applies delimiters set in config file. - $this->_config_delimiters(); + $rules = $this->_config_delimiters($rules); // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -76,9 +76,10 @@ class CI_Form_validation { /** * if prefixes/suffixes set in config, assign and unset. * - * @return void + * @param array + * @return array */ - protected function _config_delimiters() + protected function _config_delimiters($rules) { if (isset($rules['error_prefix'])) { @@ -90,6 +91,7 @@ class CI_Form_validation { $this->_error_suffix = $rules['error_suffix']; unset($rules['error_suffix']); } + return $rules; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 5d27c43d29fc049497010ea62ac7877a64bfed92 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 8 Mar 2012 12:01:52 +0200 Subject: Fix issue #940 --- system/core/Security.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Security.php b/system/core/Security.php index 6f25fb5bb..2bffa41b7 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -138,8 +138,8 @@ class CI_Security { */ public function csrf_verify() { - // If no POST data exists we will set the CSRF cookie - if (count($_POST) === 0) + // If it's not a POST request we will set the CSRF cookie + if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') { return $this->csrf_set_cookie(); } -- cgit v1.2.3-24-g4f1b From 7f42d060fb828bfb0bd857ad1a17b91070e52628 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Thu, 8 Mar 2012 09:00:57 -0500 Subject: moved delimiter assigning to constructor, removed extra function. --- system/libraries/Form_validation.php | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f3535b225..3e16d69ed 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -54,7 +54,16 @@ class CI_Form_validation { $this->CI =& get_instance(); // applies delimiters set in config file. - $rules = $this->_config_delimiters($rules); + if (isset($rules['error_prefix'])) + { + $this->_error_prefix = $rules['error_prefix']; + unset($rules['error_prefix']); + } + if (isset($rules['error_suffix'])) + { + $this->_error_suffix = $rules['error_suffix']; + unset($rules['error_suffix']); + } // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -70,29 +79,6 @@ class CI_Form_validation { log_message('debug', "Form Validation Class Initialized"); } - - // -------------------------------------------------------------------- - - /** - * if prefixes/suffixes set in config, assign and unset. - * - * @param array - * @return array - */ - protected function _config_delimiters($rules) - { - if (isset($rules['error_prefix'])) - { - $this->_error_prefix = $rules['error_prefix']; - unset($rules['error_prefix']); - } - if (isset($rules['error_suffix'])) - { - $this->_error_suffix = $rules['error_suffix']; - unset($rules['error_suffix']); - } - return $rules; - } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0aa9f2e86124194cd64fde098ba7a4169625d353 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Mar 2012 14:55:20 +0200 Subject: _protect_identifiers() to protect_identifier() --- system/database/drivers/sqlite3/sqlite3_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index 0db366eb3..6affb8745 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -303,8 +303,8 @@ class CI_DB_sqlite3_driver extends CI_DB { return 0; } - $result = $this->conn_id->querySingle($this->_count_string.$this->_protect_identifiers('numrows') - .' FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $result = $this->conn_id->querySingle($this->_count_string.$this->protect_identifiers('numrows') + .' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); return empty($result) ? 0 : (int) $result; } -- 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/core/Benchmark.php | 2 +- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 2 +- system/core/Config.php | 2 +- system/core/Controller.php | 2 +- system/core/Exceptions.php | 2 +- system/core/Hooks.php | 2 +- system/core/Input.php | 2 +- system/core/Lang.php | 2 +- system/core/Loader.php | 2 +- system/core/Model.php | 2 +- system/core/Output.php | 2 +- system/core/Router.php | 2 +- system/core/Security.php | 2 +- system/core/URI.php | 2 +- system/core/Utf8.php | 2 +- system/database/DB.php | 2 +- system/database/DB_active_rec.php | 2 +- system/database/DB_cache.php | 2 +- system/database/DB_driver.php | 2 +- system/database/DB_forge.php | 2 +- system/database/DB_result.php | 2 +- system/database/DB_utility.php | 2 +- system/database/drivers/cubrid/cubrid_driver.php | 2 +- system/database/drivers/cubrid/cubrid_forge.php | 2 +- system/database/drivers/cubrid/cubrid_result.php | 2 +- system/database/drivers/cubrid/cubrid_utility.php | 2 +- system/database/drivers/interbase/interbase_driver.php | 2 +- system/database/drivers/interbase/interbase_forge.php | 2 +- system/database/drivers/interbase/interbase_result.php | 2 +- system/database/drivers/interbase/interbase_utility.php | 2 +- system/database/drivers/mssql/mssql_driver.php | 2 +- system/database/drivers/mssql/mssql_forge.php | 2 +- system/database/drivers/mssql/mssql_result.php | 2 +- system/database/drivers/mssql/mssql_utility.php | 2 +- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/mysql/mysql_forge.php | 2 +- system/database/drivers/mysql/mysql_result.php | 2 +- system/database/drivers/mysql/mysql_utility.php | 2 +- system/database/drivers/mysqli/mysqli_driver.php | 2 +- system/database/drivers/mysqli/mysqli_forge.php | 2 +- system/database/drivers/mysqli/mysqli_result.php | 2 +- system/database/drivers/mysqli/mysqli_utility.php | 2 +- system/database/drivers/oci8/oci8_driver.php | 2 +- system/database/drivers/oci8/oci8_forge.php | 2 +- system/database/drivers/oci8/oci8_result.php | 2 +- system/database/drivers/oci8/oci8_utility.php | 2 +- system/database/drivers/odbc/odbc_driver.php | 2 +- system/database/drivers/odbc/odbc_forge.php | 2 +- system/database/drivers/odbc/odbc_result.php | 2 +- system/database/drivers/odbc/odbc_utility.php | 2 +- system/database/drivers/pdo/pdo_driver.php | 2 +- system/database/drivers/pdo/pdo_forge.php | 2 +- system/database/drivers/pdo/pdo_result.php | 2 +- system/database/drivers/pdo/pdo_utility.php | 2 +- system/database/drivers/postgre/postgre_driver.php | 2 +- system/database/drivers/postgre/postgre_forge.php | 2 +- system/database/drivers/postgre/postgre_result.php | 2 +- system/database/drivers/postgre/postgre_utility.php | 2 +- system/database/drivers/sqlite/sqlite_driver.php | 2 +- system/database/drivers/sqlite/sqlite_forge.php | 2 +- system/database/drivers/sqlite/sqlite_result.php | 2 +- system/database/drivers/sqlite/sqlite_utility.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_forge.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_result.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_utility.php | 2 +- system/helpers/array_helper.php | 2 +- system/helpers/captcha_helper.php | 2 +- system/helpers/cookie_helper.php | 2 +- system/helpers/date_helper.php | 2 +- system/helpers/directory_helper.php | 2 +- system/helpers/download_helper.php | 2 +- system/helpers/email_helper.php | 2 +- system/helpers/file_helper.php | 2 +- system/helpers/form_helper.php | 2 +- system/helpers/html_helper.php | 2 +- system/helpers/inflector_helper.php | 2 +- system/helpers/language_helper.php | 2 +- system/helpers/number_helper.php | 2 +- system/helpers/path_helper.php | 2 +- system/helpers/security_helper.php | 2 +- system/helpers/smiley_helper.php | 2 +- system/helpers/string_helper.php | 2 +- system/helpers/text_helper.php | 2 +- system/helpers/typography_helper.php | 2 +- system/helpers/url_helper.php | 2 +- system/helpers/xml_helper.php | 2 +- system/language/english/calendar_lang.php | 2 +- system/language/english/date_lang.php | 2 +- system/language/english/db_lang.php | 2 +- system/language/english/email_lang.php | 2 +- system/language/english/form_validation_lang.php | 2 +- system/language/english/ftp_lang.php | 2 +- system/language/english/imglib_lang.php | 2 +- system/language/english/migration_lang.php | 2 +- system/language/english/number_lang.php | 2 +- system/language/english/profiler_lang.php | 2 +- system/language/english/unit_test_lang.php | 2 +- system/language/english/upload_lang.php | 2 +- system/libraries/Cache/Cache.php | 2 +- system/libraries/Cache/drivers/Cache_apc.php | 2 +- system/libraries/Cache/drivers/Cache_dummy.php | 2 +- system/libraries/Cache/drivers/Cache_file.php | 2 +- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- system/libraries/Calendar.php | 2 +- system/libraries/Cart.php | 2 +- system/libraries/Driver.php | 2 +- system/libraries/Email.php | 2 +- system/libraries/Encrypt.php | 2 +- system/libraries/Form_validation.php | 2 +- system/libraries/Ftp.php | 2 +- system/libraries/Image_lib.php | 2 +- system/libraries/Javascript.php | 2 +- system/libraries/Log.php | 2 +- system/libraries/Migration.php | 2 +- system/libraries/Pagination.php | 2 +- system/libraries/Parser.php | 2 +- system/libraries/Profiler.php | 2 +- system/libraries/Session.php | 2 +- system/libraries/Table.php | 2 +- system/libraries/Trackback.php | 2 +- system/libraries/Typography.php | 2 +- system/libraries/Unit_test.php | 2 +- system/libraries/Upload.php | 2 +- system/libraries/User_agent.php | 2 +- system/libraries/Xmlrpc.php | 2 +- system/libraries/Xmlrpcs.php | 2 +- system/libraries/Zip.php | 2 +- system/libraries/javascript/Jquery.php | 2 +- 130 files changed, 130 insertions(+), 130 deletions(-) (limited to 'system') diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index f4dfd3dab..f6b634deb 100755 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.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 * diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 7af3c485d..a79a69590 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.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 * diff --git a/system/core/Common.php b/system/core/Common.php index 491979350..f20acafd4 100644 --- a/system/core/Common.php +++ b/system/core/Common.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 * diff --git a/system/core/Config.php b/system/core/Config.php index 68417435d..1e149d005 100755 --- a/system/core/Config.php +++ b/system/core/Config.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 * diff --git a/system/core/Controller.php b/system/core/Controller.php index 0dc131701..05e1bf5bf 100644 --- a/system/core/Controller.php +++ b/system/core/Controller.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 * diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index bf9901252..d7282b1f3 100755 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.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 * diff --git a/system/core/Hooks.php b/system/core/Hooks.php index e1ac58e6e..493822f36 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.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 * diff --git a/system/core/Input.php b/system/core/Input.php index ee15f4013..9a05034ba 100755 --- a/system/core/Input.php +++ b/system/core/Input.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 * diff --git a/system/core/Lang.php b/system/core/Lang.php index c40a6856e..9ef76f4d6 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.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 * diff --git a/system/core/Loader.php b/system/core/Loader.php index 12daaa928..971d30325 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.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 * diff --git a/system/core/Model.php b/system/core/Model.php index a595a6ae2..49b8d34e4 100755 --- a/system/core/Model.php +++ b/system/core/Model.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 * diff --git a/system/core/Output.php b/system/core/Output.php index abd8a0ea9..faebbbe72 100755 --- a/system/core/Output.php +++ b/system/core/Output.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 * diff --git a/system/core/Router.php b/system/core/Router.php index d21319565..b251abb4b 100755 --- a/system/core/Router.php +++ b/system/core/Router.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 * diff --git a/system/core/Security.php b/system/core/Security.php index 6f25fb5bb..bf73bd15d 100755 --- a/system/core/Security.php +++ b/system/core/Security.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 * diff --git a/system/core/URI.php b/system/core/URI.php index b28ee198b..db5b8e44b 100755 --- a/system/core/URI.php +++ b/system/core/URI.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 * diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 0e180d36f..ba3567453 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.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 * diff --git a/system/database/DB.php b/system/database/DB.php index d06ffb40e..116116bf4 100755 --- a/system/database/DB.php +++ b/system/database/DB.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 * diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index f648e5591..c7df81963 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.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 * diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index 79651fcb0..fb0cfa89a 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.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 * diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a61450d4c..59018cc91 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.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 * diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 336e9497d..fe2a67728 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.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 * diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 61aa56121..c3cdd24ff 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.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 * 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 * diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index afdaef351..1c65cbdd3 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.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 * diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 85e740057..293613e69 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.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 * diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php index 4c0fede10..a7eeb8a39 100644 --- a/system/database/drivers/cubrid/cubrid_result.php +++ b/system/database/drivers/cubrid/cubrid_result.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 * diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php index 750c0d8dd..a13c0a5e4 100644 --- a/system/database/drivers/cubrid/cubrid_utility.php +++ b/system/database/drivers/cubrid/cubrid_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 * diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index f4bd9e271..3e2ca4955 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.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 * diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 023d278ce..f46043569 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.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 * diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 4b15eee20..5bf0c902d 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.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 * diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index 76a0497c1..a88055ee0 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_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 * diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 147c63483..534e8d9a8 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.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 * diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index dd8aa3448..50db595bf 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.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 * diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index bba2e6243..b205ce2d1 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.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 * diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index be6ed5bb0..28f34b999 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_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 * diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7fd08a6ed..76fb057ea 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.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 * diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 0f251b086..3cd96a8a2 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.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 * diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index 5a65d9c72..cec28dc2d 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.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 * diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 952f887fe..d716b004a 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_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 * diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 25b6ceca1..e0b2065a1 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.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 * diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 7de036127..deb8c0d9e 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.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 * diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index 8b909cc56..f135f4d46 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.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 * diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 3fdc5c723..650ddfd18 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_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 * diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 35cafff6c..048149f30 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.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 * diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 0aa119907..e9c30e140 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.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 * diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 383b9f1a0..6f1b8b4c1 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.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 * diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index d60f98bc4..62dfb2f3c 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_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 * diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index a6e08cf2f..84e9a9801 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.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 * diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index e0ec687c8..d5c42518a 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.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 * diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index de2c58cb9..d19fa247e 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.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 * diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index bae3fe853..c146c1785 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_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 * diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 8fdfd58fb..c86d9df60 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.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 * diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 478b2dbfb..7c238473e 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.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 * diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index c333abc40..309f1947d 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.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 * diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php index 971ec8803..c278c5172 100644 --- a/system/database/drivers/pdo/pdo_utility.php +++ b/system/database/drivers/pdo/pdo_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 * diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 5b248e9bc..b8abbd742 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.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 * diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 756fd347a..216b4967c 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.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 * diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index 9161bf955..12d7547c5 100644 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.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 * diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index c426b363b..e31a6db8f 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_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 * diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 3eaec949c..efb372707 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.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 * diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index fd0f3eb98..3e9e5d4ab 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.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 * diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php index 74c0dc549..ac2235cbc 100644 --- a/system/database/drivers/sqlite/sqlite_result.php +++ b/system/database/drivers/sqlite/sqlite_result.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 * diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index 8fefcd9e2..9f9ddca44 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_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 * diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 5c90cb4f2..5e920cbe8 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.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 * diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 2a7766927..e00fc7d74 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.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 * diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php index 1ee19c2d1..52d338a30 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_result.php +++ b/system/database/drivers/sqlsrv/sqlsrv_result.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 * diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index e96df96f9..44e6fafeb 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_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 * diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index c46c4d103..e5e32c48d 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.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 * diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 668b034d4..583c2f10f 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.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 * diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 7b439c47f..b46f80540 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.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 * diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 9e58d8630..2a34cf93e 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.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 * diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php index be65b388d..1d67e056d 100644 --- a/system/helpers/directory_helper.php +++ b/system/helpers/directory_helper.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 * diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index a8c59c2c0..47d55dbf5 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.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 * diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php index f184031a9..b87bce674 100644 --- a/system/helpers/email_helper.php +++ b/system/helpers/email_helper.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 * diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 2d4b10e37..3fd6b82e1 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.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 * diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 6efef2324..4da07f283 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.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 * diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 72970d9ca..b8c4f36f6 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.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 * diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 02c425b8a..2f6b40aa7 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.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 * diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php index a83580a97..1d66df59f 100644 --- a/system/helpers/language_helper.php +++ b/system/helpers/language_helper.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 * diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php index 331b468c6..b6c823d8b 100644 --- a/system/helpers/number_helper.php +++ b/system/helpers/number_helper.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 * diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index cd87a73eb..2eb85fefa 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.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 * diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 99fda561a..e05e947a5 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.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 * diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 700f4486c..cc903bc1c 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.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 * diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index 04d51c2f9..607a12bcb 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.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 * diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 6e9ea570f..7591bac5f 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.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 * diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php index c49348e6a..9b19c7c2d 100644 --- a/system/helpers/typography_helper.php +++ b/system/helpers/typography_helper.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 * diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 3f0fef58e..2ae1fd37b 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.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 * diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php index 5242193ac..f3ff5764c 100644 --- a/system/helpers/xml_helper.php +++ b/system/helpers/xml_helper.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 * diff --git a/system/language/english/calendar_lang.php b/system/language/english/calendar_lang.php index bf61db039..2d477e6c8 100644 --- a/system/language/english/calendar_lang.php +++ b/system/language/english/calendar_lang.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 * diff --git a/system/language/english/date_lang.php b/system/language/english/date_lang.php index cd6cf39c4..533563700 100644 --- a/system/language/english/date_lang.php +++ b/system/language/english/date_lang.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 * diff --git a/system/language/english/db_lang.php b/system/language/english/db_lang.php index 2a91597df..a135d1aac 100644 --- a/system/language/english/db_lang.php +++ b/system/language/english/db_lang.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 * diff --git a/system/language/english/email_lang.php b/system/language/english/email_lang.php index e0ef427a6..23296a244 100644 --- a/system/language/english/email_lang.php +++ b/system/language/english/email_lang.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 * diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index ea589618a..6cf0b46f4 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.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 * diff --git a/system/language/english/ftp_lang.php b/system/language/english/ftp_lang.php index 18ca92713..4e39e43bf 100644 --- a/system/language/english/ftp_lang.php +++ b/system/language/english/ftp_lang.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 * diff --git a/system/language/english/imglib_lang.php b/system/language/english/imglib_lang.php index fbb92abfb..67ca94277 100644 --- a/system/language/english/imglib_lang.php +++ b/system/language/english/imglib_lang.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 * diff --git a/system/language/english/migration_lang.php b/system/language/english/migration_lang.php index 9765562b5..2085cee2a 100644 --- a/system/language/english/migration_lang.php +++ b/system/language/english/migration_lang.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 * diff --git a/system/language/english/number_lang.php b/system/language/english/number_lang.php index 5dfd882ed..0c19ec614 100644 --- a/system/language/english/number_lang.php +++ b/system/language/english/number_lang.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 * diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php index 1d10efa76..11d791272 100644 --- a/system/language/english/profiler_lang.php +++ b/system/language/english/profiler_lang.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 * diff --git a/system/language/english/unit_test_lang.php b/system/language/english/unit_test_lang.php index ed98439f4..3a8e14403 100644 --- a/system/language/english/unit_test_lang.php +++ b/system/language/english/unit_test_lang.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 * diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php index a9a2fe74b..ec5de1e6b 100644 --- a/system/language/english/upload_lang.php +++ b/system/language/english/upload_lang.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 * diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 2e78a6660..60998e3b8 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.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 * diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index a3dd46978..c387a30fc 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.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 * diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index fcd55da39..c9767e401 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.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 * diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index a960730d7..c0be0def4 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.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 * diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index ffe6f2ff7..b8f2d7e4c 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.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 * diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index a05a7babf..6c04de8a2 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.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 * diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 10b5362a5..60a1e52fe 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.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 * diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 4e8944311..9a073b336 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.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 * diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 8d839d0c9..f30fe40b6 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.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 * diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 0b0618991..b29eb470e 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.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 * diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index cdb3d3d62..8153af706 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.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 * diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index ab395b0a0..4d96c00cc 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.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 * diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 9826eabdd..86b77bf07 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.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 * diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 33df6007a..9ba93000b 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.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 * diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 944173fdd..955277acc 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.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 * diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index d07097223..c045ac0e2 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.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 * diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 35ac541e8..86b8d79fa 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.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 * diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 321248277..290e17fc0 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.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 * diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 04216be5d..d84e5d3fc 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.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 * diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 104b88810..0b9d45b2a 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.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 * diff --git a/system/libraries/Table.php b/system/libraries/Table.php index fb154e50f..8651b9e69 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.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 * diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 79a009133..3bea5f9b8 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.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 * diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 46c73ef8b..65e30b089 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.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 * diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 38d767c69..2eb8df356 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.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 * diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 89575c849..42664a587 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.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 * diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index cd644c00d..9109edd0f 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.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 * diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 730a0fc49..32e2e523b 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.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 * diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 355d43f29..fc41444bc 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.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 * diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 50e84920e..e33eb4e5a 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.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 * diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index 03574c66e..f30d7c639 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.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 ca6404749a8dd3ee5dd68d64832374dce05fe6a3 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:19:35 +0000 Subject: Allow arrays to be used for enum/set constraint. This was working in MySQL but not MySQLi. --- system/database/drivers/mysqli/mysqli_forge.php | 29 ++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 4ab7a639d..9cb1a0c70 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -86,9 +86,32 @@ class CI_DB_mysqli_forge extends CI_DB_forge { $sql .= "\n\t".$this->db->protect_identifiers($field) .( ! empty($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '') - .( ! empty($attributes['TYPE']) ? ' '.$attributes['TYPE'] : '') - .( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '') - .(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') + ; + + if ( ! empty($attributes['TYPE'])) + { + $sql .= ' '.$attributes['TYPE']; + + if ( ! empty($attributes['CONSTRAINT'])) + { + switch (strtolower($attributes['TYPE'])) + { + case 'decimal': + case 'float': + case 'numeric': + $sql .= '('.implode(',', $attributes['CONSTRAINT']).')'; + break; + case 'enum': + case 'set': + $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")'; + break; + default: + $sql .= '('.$attributes['CONSTRAINT'].')'; + } + } + } + + $sql .= (( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '') .(isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') .(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') .(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : ''); -- cgit v1.2.3-24-g4f1b From 10aa8e660c6f439958b79fce5d85ce7e8eecf028 Mon Sep 17 00:00:00 2001 From: Joel Kallman Date: Fri, 9 Mar 2012 14:54:53 -0500 Subject: Adding Support to Properly Escape Objects that have __toString() magic method so that the object can be passed directly as a parameter in a condition without having to manually convert to a string Signed-off-by: Joel Kallman --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 9d92f2f87..a72bf3101 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -727,7 +727,7 @@ class CI_DB_driver { */ function escape($str) { - if (is_string($str)) + if (is_string($str) OR method_exists($str, '__toString')) { $str = "'".$this->escape_str($str)."'"; } -- cgit v1.2.3-24-g4f1b From 9929d6f77a0e54288b1696343439b0e91b21866e Mon Sep 17 00:00:00 2001 From: Christopher Guiney Date: Fri, 9 Mar 2012 19:53:24 -0800 Subject: Allow drivers to be loaded as an array, like models and libraries. --- system/core/Loader.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Loader.php b/system/core/Loader.php index 3d91915c4..42d8162bb 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -615,13 +615,22 @@ class CI_Loader { * * Loads a driver library * - * @param string the name of the class + * @param mixed the name of the class or array of classes * @param mixed the optional parameters * @param string an optional object name * @return void */ public function driver($library = '', $params = NULL, $object_name = NULL) { + if(is_array($library)) + { + foreach ( $library as $driver ) + { + $this->driver($driver); + } + return FALSE; + } + if ( ! class_exists('CI_Driver_Library')) { // we aren't instantiating an object here, that'll be done by the Library itself -- cgit v1.2.3-24-g4f1b From 4da9478ca00a9316c525b71001e0c6260d7d85fa Mon Sep 17 00:00:00 2001 From: dododedodonl Date: Sat, 10 Mar 2012 13:56:17 +0100 Subject: Removed quotes from the Content-Type header to support mime-type detection on android --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 47d55dbf5..f3f0ff2ca 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -91,7 +91,7 @@ if ( ! function_exists('force_download')) } // Generate the server headers - header('Content-Type: "'.$mime.'"'); + header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="'.$filename.'"'); header('Expires: 0'); header('Content-Transfer-Encoding: binary'); -- cgit v1.2.3-24-g4f1b From e40c763bf969acbaa7c4c61be50f01e870062080 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sat, 10 Mar 2012 13:05:08 +0000 Subject: Fixed camelize. --- system/helpers/inflector_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 02c425b8a..5acfd6bc5 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -173,7 +173,7 @@ if ( ! function_exists('camelize')) { function camelize($str) { - return substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1); + return strtolower($str[0]).substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1); } } -- cgit v1.2.3-24-g4f1b From 52a31ba3acc5f5be16692ac25c70780775e548e0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 10 Mar 2012 15:38:49 +0200 Subject: Fix camelize() --- system/helpers/inflector_helper.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 2f6b40aa7..bbc75c747 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Inflector Helpers * @@ -37,7 +35,6 @@ * @link http://codeigniter.com/user_guide/helpers/inflector_helper.html */ - // -------------------------------------------------------------------- /** @@ -58,7 +55,7 @@ if ( ! function_exists('singular')) { return $result; } - + $singular_rules = array( '/(matr)ices$/' => '\1ix', '/(vert|ind)ices$/' => '\1ex', @@ -116,7 +113,7 @@ if ( ! function_exists('singular')) if ( ! function_exists('plural')) { function plural($str, $force = FALSE) - { + { $result = strval($str); if ( ! is_countable($result)) @@ -145,7 +142,7 @@ if ( ! function_exists('plural')) '/s$/' => 's', // no change (compatibility) '/$/' => 's', ); - + foreach ($plural_rules as $rule => $replacement) { if (preg_match($rule, $result)) @@ -173,7 +170,7 @@ if ( ! function_exists('camelize')) { function camelize($str) { - return substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1); + return ucwords(str_replace(' ', '', preg_replace('/[\s_]+/', ' ', strtolower($str)))); } } @@ -232,4 +229,4 @@ if ( ! function_exists('is_countable')) } /* End of file inflector_helper.php */ -/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/inflector_helper.php */ -- cgit v1.2.3-24-g4f1b From 1ae651655888383a4d7f97fbf6e97a7ac00a9630 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 10 Mar 2012 16:11:34 +0200 Subject: Remove PHP 5.1.6-specific code --- system/core/Input.php | 31 +------------------------------ system/core/URI.php | 4 +--- 2 files changed, 2 insertions(+), 33 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 54b7e0923..901b4147e 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -366,36 +366,7 @@ class CI_Input { */ public function valid_ip($ip) { - // if php version >= 5.2, use filter_var to check validate ip. - if (function_exists('filter_var')) - { - return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); - } - - $ip_segments = explode('.', $ip); - - // Always 4 segments needed - if (count($ip_segments) !== 4) - { - return FALSE; - } - // IP can not start with 0 - if ($ip_segments[0][0] == '0') - { - return FALSE; - } - // Check each segment - foreach ($ip_segments as $segment) - { - // IP segments must be digits and can not be - // longer than 3 digits or greater then 255 - if ($segment == '' OR preg_match('/[^0-9]/', $segment) OR $segment > 255 OR strlen($segment) > 3) - { - return FALSE; - } - } - - return TRUE; + return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); } // -------------------------------------------------------------------- diff --git a/system/core/URI.php b/system/core/URI.php index db5b8e44b..4a2e87c2a 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -444,9 +444,7 @@ class CI_URI { return array(); } - return function_exists('array_fill_keys') - ? array_fill_keys($default, FALSE) - : array_combine($default, array_fill(0, count($default), FALSE)); + return array_fill_keys($default, FALSE); } $segments = array_slice($this->$segment_array(), ($n - 1)); -- cgit v1.2.3-24-g4f1b From c6dfcca21f5f5cb7b2572776c251683d53c669c1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 10 Mar 2012 16:16:48 +0200 Subject: Really fix camelize() --- system/helpers/inflector_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index bbc75c747..9cf015d2b 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -170,7 +170,7 @@ if ( ! function_exists('camelize')) { function camelize($str) { - return ucwords(str_replace(' ', '', preg_replace('/[\s_]+/', ' ', strtolower($str)))); + return str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', strtolower($str)))); } } -- cgit v1.2.3-24-g4f1b From b54d355faabef775703119a23dd55004b84a1140 Mon Sep 17 00:00:00 2001 From: Christopher Guiney Date: Sat, 10 Mar 2012 08:38:10 -0800 Subject: Fixing some spacing. --- system/core/Loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Loader.php b/system/core/Loader.php index 42d8162bb..9b9cc2fef 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -622,9 +622,9 @@ class CI_Loader { */ public function driver($library = '', $params = NULL, $object_name = NULL) { - if(is_array($library)) + if (is_array($library)) { - foreach ( $library as $driver ) + foreach ($library as $driver) { $this->driver($driver); } -- cgit v1.2.3-24-g4f1b From 8749bc7e836c196dfef37d3b7b5a67736a15092c Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 11 Mar 2012 05:43:45 +0700 Subject: Fix incomplete and skipped test --- system/core/Config.php | 2 +- system/libraries/Table.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/Config.php b/system/core/Config.php index 68417435d..5424e5eb1 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,7 +76,7 @@ class CI_Config { log_message('debug', 'Config Class Initialized'); // Set the base_url automatically if none was provided - if ($this->config['base_url'] == '') + if (empty($this->config['base_url'])) { if (isset($_SERVER['HTTP_HOST'])) { diff --git a/system/libraries/Table.php b/system/libraries/Table.php index fb154e50f..8f6ac8d45 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -102,7 +102,7 @@ class CI_Table { */ public function make_columns($array = array(), $col_limit = 0) { - if ( ! is_array($array) OR count($array) === 0) + if ( ! is_array($array) OR count($array) === 0 OR ! is_int($col_limit)) { return FALSE; } @@ -395,7 +395,7 @@ class CI_Table { // First generate the headings from the table column names if (count($this->heading) === 0) { - if ( ! method_exists($query, 'list_fields')) + if ( ! is_callable(array($query, 'list_fields'))) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 03dbcf0669abdddf6bb459a423b99e7aed73e453 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 11:48:50 +0000 Subject: Make timespan() helper show fuzzier periods if required --- system/helpers/date_helper.php | 131 +++++++++++++++++++++++++++-------------- 1 file changed, 86 insertions(+), 45 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 2a34cf93e..9f8e05bb9 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -163,7 +163,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '') + function timespan($seconds = 1, $time = '', $units = '') { $CI =& get_instance(); $CI->lang->load('date'); @@ -178,83 +178,124 @@ if ( ! function_exists('timespan')) $time = time(); } - $seconds = ($time <= $seconds) ? 1 : $time - $seconds; + if ( ! is_numeric($units)) + { + $units = 999; + } + + if ($time <= $seconds) + { + $seconds = 1; + } + else + { + $seconds = $time - $seconds; + } - $str = ''; - $years = floor($seconds / 31557600); + $str = array(); + + // years + + $years = floor($seconds / 31536000); if ($years > 0) { - $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; + $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')); } - $seconds -= $years * 31557600; - $months = floor($seconds / 2629743); + $seconds -= $years * 31536000; - if ($years > 0 OR $months > 0) - { - if ($months > 0) + // months + + if (count($str) < $units) { + $months = floor($seconds / 2628000); + + if ($years > 0 OR $months > 0) { - $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; - } + if ($months > 0) + { + $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')); + } - $seconds -= $months * 2629743; + $seconds -= $months * 2628000; + } } - $weeks = floor($seconds / 604800); + // weeks + + if (count($str) < $units) { + $weeks = floor($seconds / 604800); - if ($years > 0 OR $months > 0 OR $weeks > 0) - { - if ($weeks > 0) + if ($years > 0 OR $months > 0 OR $weeks > 0) { - $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', '; - } + if ($weeks > 0) + { + $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')); + } - $seconds -= $weeks * 604800; + $seconds -= $weeks * 604800; + } } - $days = floor($seconds / 86400); + // days - if ($months > 0 OR $weeks > 0 OR $days > 0) - { - if ($days > 0) + if (count($str) < $units) { + $days = floor($seconds / 86400); + + if ($months > 0 OR $weeks > 0 OR $days > 0) { - $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', '; - } + if ($days > 0) + { + $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')); + } - $seconds -= $days * 86400; + $seconds -= $days * 86400; + } } - $hours = floor($seconds / 3600); + // hours - if ($days > 0 OR $hours > 0) - { - if ($hours > 0) + if (count($str) < $units) { + + $hours = floor($seconds / 3600); + + if ($days > 0 OR $hours > 0) { - $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', '; - } + if ($hours > 0) + { + $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')); + } - $seconds -= $hours * 3600; + $seconds -= $hours * 3600; + } } - $minutes = floor($seconds / 60); + // minutes - if ($days > 0 OR $hours > 0 OR $minutes > 0) - { - if ($minutes > 0) + if (count($str) < $units) { + + $minutes = floor($seconds / 60); + + if ($days > 0 OR $hours > 0 OR $minutes > 0) { - $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', '; - } + if ($minutes > 0) + { + $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')); + } - $seconds -= $minutes * 60; + $seconds -= $minutes * 60; + } } - if ($str == '') - { - $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', '; + // seconds + + if (count($str) == 0) { + { + $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); + } } - return substr(trim($str), 0, -1); + return strtolower(implode(', ', $str)); } } -- cgit v1.2.3-24-g4f1b From 11f46f736b93529e8310135669196dec98e94d90 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 15:11:44 +0000 Subject: Revert "Make timespan() helper show fuzzier periods if required" This reverts commit 03dbcf0669abdddf6bb459a423b99e7aed73e453. --- system/helpers/date_helper.php | 131 ++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 86 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 9f8e05bb9..2a34cf93e 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -163,7 +163,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '', $units = '') + function timespan($seconds = 1, $time = '') { $CI =& get_instance(); $CI->lang->load('date'); @@ -178,124 +178,83 @@ if ( ! function_exists('timespan')) $time = time(); } - if ( ! is_numeric($units)) - { - $units = 999; - } - - if ($time <= $seconds) - { - $seconds = 1; - } - else - { - $seconds = $time - $seconds; - } + $seconds = ($time <= $seconds) ? 1 : $time - $seconds; - $str = array(); - - // years - - $years = floor($seconds / 31536000); + $str = ''; + $years = floor($seconds / 31557600); if ($years > 0) { - $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')); + $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; } - $seconds -= $years * 31536000; + $seconds -= $years * 31557600; + $months = floor($seconds / 2629743); - // months - - if (count($str) < $units) { - $months = floor($seconds / 2628000); - - if ($years > 0 OR $months > 0) + if ($years > 0 OR $months > 0) + { + if ($months > 0) { - if ($months > 0) - { - $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')); - } - - $seconds -= $months * 2628000; + $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; } + + $seconds -= $months * 2629743; } - // weeks - - if (count($str) < $units) { - $weeks = floor($seconds / 604800); + $weeks = floor($seconds / 604800); - if ($years > 0 OR $months > 0 OR $weeks > 0) + if ($years > 0 OR $months > 0 OR $weeks > 0) + { + if ($weeks > 0) { - if ($weeks > 0) - { - $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')); - } - - $seconds -= $weeks * 604800; + $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', '; } - } - // days + $seconds -= $weeks * 604800; + } - if (count($str) < $units) { - $days = floor($seconds / 86400); + $days = floor($seconds / 86400); - if ($months > 0 OR $weeks > 0 OR $days > 0) + if ($months > 0 OR $weeks > 0 OR $days > 0) + { + if ($days > 0) { - if ($days > 0) - { - $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')); - } - - $seconds -= $days * 86400; + $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', '; } - } - // hours - - if (count($str) < $units) { + $seconds -= $days * 86400; + } - $hours = floor($seconds / 3600); + $hours = floor($seconds / 3600); - if ($days > 0 OR $hours > 0) + if ($days > 0 OR $hours > 0) + { + if ($hours > 0) { - if ($hours > 0) - { - $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')); - } - - $seconds -= $hours * 3600; + $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', '; } - } - - // minutes - if (count($str) < $units) { + $seconds -= $hours * 3600; + } - $minutes = floor($seconds / 60); + $minutes = floor($seconds / 60); - if ($days > 0 OR $hours > 0 OR $minutes > 0) + if ($days > 0 OR $hours > 0 OR $minutes > 0) + { + if ($minutes > 0) { - if ($minutes > 0) - { - $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')); - } - - $seconds -= $minutes * 60; + $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', '; } - } - // seconds + $seconds -= $minutes * 60; + } - if (count($str) == 0) { - { - $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); - } + if ($str == '') + { + $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', '; } - return strtolower(implode(', ', $str)); + return substr(trim($str), 0, -1); } } -- cgit v1.2.3-24-g4f1b From 04c146d95dbc1c86e477bd27798d3234f74833e0 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 15:31:01 +0000 Subject: refactored to start from latest version, also less diff pain --- system/helpers/date_helper.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 2a34cf93e..70b01e348 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -163,7 +163,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '') + function timespan($seconds = 1, $time = '', $units = '') { $CI =& get_instance(); $CI->lang->load('date'); @@ -178,24 +178,29 @@ if ( ! function_exists('timespan')) $time = time(); } + if ( ! is_numeric($units)) + { + $units = 999; + } + $seconds = ($time <= $seconds) ? 1 : $time - $seconds; - $str = ''; + $str = array(); $years = floor($seconds / 31557600); if ($years > 0) { - $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; + $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')); } $seconds -= $years * 31557600; $months = floor($seconds / 2629743); - if ($years > 0 OR $months > 0) + if (count($str) < $units AND ($years > 0 OR $months > 0)) { if ($months > 0) { - $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; + $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')); } $seconds -= $months * 2629743; @@ -203,11 +208,11 @@ if ( ! function_exists('timespan')) $weeks = floor($seconds / 604800); - if ($years > 0 OR $months > 0 OR $weeks > 0) + if (count($str) < $units AND ($years > 0 OR $months > 0 OR $weeks > 0)) { if ($weeks > 0) { - $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', '; + $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')); } $seconds -= $weeks * 604800; @@ -215,11 +220,11 @@ if ( ! function_exists('timespan')) $days = floor($seconds / 86400); - if ($months > 0 OR $weeks > 0 OR $days > 0) + if (count($str) < $units AND ($months > 0 OR $weeks > 0 OR $days > 0)) { if ($days > 0) { - $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', '; + $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')); } $seconds -= $days * 86400; @@ -227,11 +232,11 @@ if ( ! function_exists('timespan')) $hours = floor($seconds / 3600); - if ($days > 0 OR $hours > 0) + if (count($str) < $units AND ($days > 0 OR $hours > 0)) { if ($hours > 0) { - $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', '; + $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')); } $seconds -= $hours * 3600; @@ -239,11 +244,11 @@ if ( ! function_exists('timespan')) $minutes = floor($seconds / 60); - if ($days > 0 OR $hours > 0 OR $minutes > 0) + if (count($str) < $units AND ($days > 0 OR $hours > 0 OR $minutes > 0)) { if ($minutes > 0) { - $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', '; + $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')); } $seconds -= $minutes * 60; @@ -251,10 +256,10 @@ if ( ! function_exists('timespan')) if ($str == '') { - $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', '; + $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); } - return substr(trim($str), 0, -1); + return implode(', ', $str); } } -- cgit v1.2.3-24-g4f1b From b8fb66b38e233c82f0116f9bdb0fdfd4ee074b30 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Sun, 11 Mar 2012 16:15:15 +0000 Subject: AND -> && --- system/helpers/date_helper.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 70b01e348..e792ecc43 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -196,7 +196,7 @@ if ( ! function_exists('timespan')) $seconds -= $years * 31557600; $months = floor($seconds / 2629743); - if (count($str) < $units AND ($years > 0 OR $months > 0)) + if (count($str) < $units && ($years > 0 OR $months > 0)) { if ($months > 0) { @@ -208,7 +208,7 @@ if ( ! function_exists('timespan')) $weeks = floor($seconds / 604800); - if (count($str) < $units AND ($years > 0 OR $months > 0 OR $weeks > 0)) + if (count($str) < $units && ($years > 0 OR $months > 0 OR $weeks > 0)) { if ($weeks > 0) { @@ -220,7 +220,7 @@ if ( ! function_exists('timespan')) $days = floor($seconds / 86400); - if (count($str) < $units AND ($months > 0 OR $weeks > 0 OR $days > 0)) + if (count($str) < $units && ($months > 0 OR $weeks > 0 OR $days > 0)) { if ($days > 0) { @@ -232,7 +232,7 @@ if ( ! function_exists('timespan')) $hours = floor($seconds / 3600); - if (count($str) < $units AND ($days > 0 OR $hours > 0)) + if (count($str) < $units && ($days > 0 OR $hours > 0)) { if ($hours > 0) { @@ -244,7 +244,7 @@ if ( ! function_exists('timespan')) $minutes = floor($seconds / 60); - if (count($str) < $units AND ($days > 0 OR $hours > 0 OR $minutes > 0)) + if (count($str) < $units && ($days > 0 OR $hours > 0 OR $minutes > 0)) { if ($minutes > 0) { -- cgit v1.2.3-24-g4f1b From fce2ed6d1d3026c485e79ce5bf236effc67981be Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Mar 2012 22:04:48 +0200 Subject: Added an Android <= 2.1 specific check to force_download() --- system/helpers/download_helper.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index f3f0ff2ca..34f9bc07d 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -60,19 +60,19 @@ if ( ! function_exists('force_download')) // Set the default MIME type to send $mime = 'application/octet-stream'; + $x = explode('.', $filename); + $extension = end($x); + if ($set_mime === TRUE) { - /* If we're going to detect the MIME type, - * we'll need a file extension. - */ - if (FALSE === strpos($filename, '.')) + if (count($x) === 1 OR $extension === '') { + /* If we're going to detect the MIME type, + * we'll need a file extension. + */ return FALSE; } - $extension = explode('.', $filename); - $extension = end($extension); - // Load the mime types if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { @@ -90,6 +90,18 @@ if ( ! function_exists('force_download')) } } + /* It was reported that browsers on Android 2.1 (and possibly older as well) + * need to have the filename extension upper-cased in order to be able to + * download it. + * + * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/ + */ + if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[12])/', $_SERVER['HTTP_USER_AGENT'])) + { + $x[count($x) - 1] = strtoupper($extension); + $filename = implode('.', $x); + } + // Generate the server headers header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="'.$filename.'"'); -- cgit v1.2.3-24-g4f1b From 3d933b6fad72d4b92f18187dd57f1d3c35f8936a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Mar 2012 22:08:57 +0200 Subject: Fix erroneus regex from previous commit --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 34f9bc07d..96ff29dec 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -96,7 +96,7 @@ if ( ! function_exists('force_download')) * * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/ */ - if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[12])/', $_SERVER['HTTP_USER_AGENT'])) + if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[01])/', $_SERVER['HTTP_USER_AGENT'])) { $x[count($x) - 1] = strtoupper($extension); $filename = implode('.', $x); -- cgit v1.2.3-24-g4f1b From 20bd7bc3f9e3c370954a0abead4f87043b99e040 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 09:26:40 +0200 Subject: Fix _limit() --- system/database/drivers/sqlite3/sqlite3_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index 6affb8745..ae0091cea 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -544,7 +544,7 @@ class CI_DB_sqlite3_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - return $sql.($offset ? $offset.',' : '').$limit; + return $sql.' LIMIT '.($offset ? $offset.',' : '').$limit; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0ba29f5aa019b9c4a002fbecacf6ed33f3b68a3d Mon Sep 17 00:00:00 2001 From: nihaopaul Date: Mon, 12 Mar 2012 16:46:58 +0800 Subject: form_dropdown() will now also take an array for unity with other form helpers. --- system/helpers/form_helper.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 4da07f283..9610cee98 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -314,6 +314,23 @@ if ( ! function_exists('form_dropdown')) { function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') { + // If name is really an array then we'll call the function again using the array + if ( is_array($name) ) { + if ( ! isset($name['options'])) + { + $name['selected'] = false; + } + if ( ! isset($name['selected'])) + { + $name['selected'] = false; + } + if ( ! isset($name['extra'])) + { + $name['extra'] = false; + } + return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']); + } + if ( ! is_array($selected)) { $selected = array($selected); -- cgit v1.2.3-24-g4f1b From ca5cabc29483921dba05343cd30734980b696fd1 Mon Sep 17 00:00:00 2001 From: nihaopaul Date: Mon, 12 Mar 2012 16:54:04 +0800 Subject: form_dropdown() will now also take an array for unity with other form helpers., codestyle cleanup only --- system/helpers/form_helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 9610cee98..efe5dbce1 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -315,7 +315,8 @@ if ( ! function_exists('form_dropdown')) function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') { // If name is really an array then we'll call the function again using the array - if ( is_array($name) ) { + if (is_array($name)) + { if ( ! isset($name['options'])) { $name['selected'] = false; -- cgit v1.2.3-24-g4f1b From 10ecad5238fe1a408e9ecbe6ed3b37c4f3d33863 Mon Sep 17 00:00:00 2001 From: nihaopaul Date: Mon, 12 Mar 2012 16:54:17 +0800 Subject: form_dropdown() will now also take an array for unity with other form helpers., codestyle cleanup only --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index efe5dbce1..ab3a12961 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -315,7 +315,7 @@ if ( ! function_exists('form_dropdown')) function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') { // If name is really an array then we'll call the function again using the array - if (is_array($name)) + if (is_array($name)) { if ( ! isset($name['options'])) { -- cgit v1.2.3-24-g4f1b From 4252f8d2e72ed25883682e4a7e2c7a221a743dc8 Mon Sep 17 00:00:00 2001 From: nihaopaul Date: Mon, 12 Mar 2012 16:57:44 +0800 Subject: form_dropdown() will now also take an array for unity with other form helpers., false => FALSE and the options check fixed --- system/helpers/form_helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index ab3a12961..8ccab99a2 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -319,15 +319,15 @@ if ( ! function_exists('form_dropdown')) { if ( ! isset($name['options'])) { - $name['selected'] = false; + $name['options'] = FALSE; } if ( ! isset($name['selected'])) { - $name['selected'] = false; + $name['selected'] = FALSE; } if ( ! isset($name['extra'])) { - $name['extra'] = false; + $name['extra'] = FALSE; } return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']); } -- cgit v1.2.3-24-g4f1b From 8abb67c6a941ea87156f2afe976724ae1cf88c03 Mon Sep 17 00:00:00 2001 From: nihaopaul Date: Mon, 12 Mar 2012 17:00:32 +0800 Subject: code readability improvements --- system/helpers/form_helper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 8ccab99a2..82a4b9f57 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -317,18 +317,22 @@ if ( ! function_exists('form_dropdown')) // If name is really an array then we'll call the function again using the array if (is_array($name)) { + if ( ! isset($name['options'])) { $name['options'] = FALSE; - } + } + if ( ! isset($name['selected'])) { $name['selected'] = FALSE; } + if ( ! isset($name['extra'])) { $name['extra'] = FALSE; } + return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']); } -- cgit v1.2.3-24-g4f1b From b6a84432400736bb7f7b835739b1ffff252f92cd Mon Sep 17 00:00:00 2001 From: nihaopaul Date: Mon, 12 Mar 2012 17:06:42 +0800 Subject: test if isset(['name']) is actually set instead of assuming it to be --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 82a4b9f57..df28d88eb 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -315,7 +315,7 @@ if ( ! function_exists('form_dropdown')) function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') { // If name is really an array then we'll call the function again using the array - if (is_array($name)) + if (is_array($name) && isset($name['name'])) { if ( ! isset($name['options'])) -- cgit v1.2.3-24-g4f1b From 08631577a008b0d7544c6092652f6140885298a5 Mon Sep 17 00:00:00 2001 From: nihaopaul Date: Mon, 12 Mar 2012 17:18:57 +0800 Subject: defaults for the function --- system/helpers/form_helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index df28d88eb..37337d975 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -320,17 +320,17 @@ if ( ! function_exists('form_dropdown')) if ( ! isset($name['options'])) { - $name['options'] = FALSE; + $name['options'] = array(); } if ( ! isset($name['selected'])) { - $name['selected'] = FALSE; + $name['selected'] = array(); } if ( ! isset($name['extra'])) { - $name['extra'] = FALSE; + $name['extra'] = ''; } return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']); -- cgit v1.2.3-24-g4f1b From 5e2cd01f1fac2bcfad60bc2bfc5823c59475a285 Mon Sep 17 00:00:00 2001 From: Seb Pollard Date: Mon, 12 Mar 2012 11:32:09 +0000 Subject: Fixed typo in English language file for upload library. --- system/language/english/upload_lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php index ec5de1e6b..4fa8394ec 100644 --- a/system/language/english/upload_lang.php +++ b/system/language/english/upload_lang.php @@ -35,7 +35,7 @@ $lang['upload_stopped_by_extension'] = "The file upload was stopped by extension $lang['upload_no_file_selected'] = "You did not select a file to upload."; $lang['upload_invalid_filetype'] = "The filetype you are attempting to upload is not allowed."; $lang['upload_invalid_filesize'] = "The file you are attempting to upload is larger than the permitted size."; -$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceedes the maximum height or width."; +$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceeds the maximum height or width."; $lang['upload_destination_error'] = "A problem was encountered while attempting to move the uploaded file to the final destination."; $lang['upload_no_filepath'] = "The upload path does not appear to be valid."; $lang['upload_no_file_types'] = "You have not specified any allowed file types."; -- cgit v1.2.3-24-g4f1b From b81f909f8aaa3bedc3820c0d4c9056b57113b46e Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Mon, 12 Mar 2012 12:46:02 +0000 Subject: updated docs & changelog --- system/helpers/date_helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index e792ecc43..2ad287b4a 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -159,7 +159,8 @@ if ( ! function_exists('standard_date')) * @access public * @param integer a number of seconds * @param integer Unix timestamp - * @return integer + * @param integer a number of display units + * @return string */ if ( ! function_exists('timespan')) { -- cgit v1.2.3-24-g4f1b From f6a4114e57a305d0b2fd24a23f9e643290e71eec Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 15:34:10 +0200 Subject: Remove usage of SET NAMES and the deprecated mysql_escape_string() from MySQL/MySQLi drivers --- system/database/drivers/mysql/mysql_driver.php | 17 ++--------------- system/database/drivers/mysqli/mysqli_driver.php | 17 ++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7f4a4f2ca..0ca8413da 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -149,9 +149,7 @@ class CI_DB_mysql_driver extends CI_DB { */ protected function _db_set_charset($charset, $collation) { - return function_exists('mysql_set_charset') - ? @mysql_set_charset($charset, $this->conn_id) - : @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id); + return @mysql_set_charset($charset, $this->conn_id) } // -------------------------------------------------------------------- @@ -289,18 +287,7 @@ class CI_DB_mysql_driver extends CI_DB { return $str; } - if (function_exists('mysql_real_escape_string') && is_resource($this->conn_id)) - { - $str = mysql_real_escape_string($str, $this->conn_id); - } - elseif (function_exists('mysql_escape_string')) - { - $str = mysql_escape_string($str); - } - else - { - $str = addslashes($str); - } + $str = is_resource($this->conn_id) ? mysql_real_escape_string($str, $this->conn_id) : addslashes($str); // escape LIKE condition wildcards if ($like === TRUE) diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 846ec0340..a965e619a 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -149,9 +149,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ protected function _db_set_charset($charset, $collation) { - return function_exists('mysqli_set_charset') - ? @mysqli_set_charset($this->conn_id, $charset) - : @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'"); + return @mysqli_set_charset($this->conn_id, $charset) } // -------------------------------------------------------------------- @@ -289,18 +287,7 @@ class CI_DB_mysqli_driver extends CI_DB { return $str; } - if (function_exists('mysqli_real_escape_string') && is_object($this->conn_id)) - { - $str = mysqli_real_escape_string($this->conn_id, $str); - } - elseif (function_exists('mysql_escape_string')) - { - $str = mysql_escape_string($str); - } - else - { - $str = addslashes($str); - } + $str = is_object($this->conn_id) ? mysqli_real_escape_string($this->conn_id, $str) : addslashes($str); // escape LIKE condition wildcards if ($like === TRUE) -- cgit v1.2.3-24-g4f1b From b3442a165a091c552a3331ece94297d5fe316fee Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 15:35:40 +0200 Subject: Add missing semicolons --- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/mysqli/mysqli_driver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 0ca8413da..071ce4327 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -149,7 +149,7 @@ class CI_DB_mysql_driver extends CI_DB { */ protected function _db_set_charset($charset, $collation) { - return @mysql_set_charset($charset, $this->conn_id) + return @mysql_set_charset($charset, $this->conn_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index a965e619a..e84b8346d 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -149,7 +149,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ protected function _db_set_charset($charset, $collation) { - return @mysqli_set_charset($this->conn_id, $charset) + return @mysqli_set_charset($this->conn_id, $charset); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From dc3de15b02eb768cf9e0a410b0d914523d019a67 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 15:41:49 +0200 Subject: Fix escape_str() and change _prep_query() to just return the query --- system/database/drivers/sqlite3/sqlite3_driver.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index ae0091cea..ed081102b 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -146,7 +146,6 @@ class CI_DB_sqlite3_driver extends CI_DB { protected function _execute($sql) { // TODO: Implement use of SQLite3::querySingle(), if needed - // TODO: Use $this->_prep_query(), if needed return $this->is_write_type($sql) ? $this->conn_id->exec($sql) @@ -165,7 +164,7 @@ class CI_DB_sqlite3_driver extends CI_DB { */ protected function _prep_query($sql) { - return $this->conn_id->prepare($sql); + return $sql; } // -------------------------------------------------------------------- @@ -253,8 +252,8 @@ class CI_DB_sqlite3_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - return str_replace(array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), + return str_replace(array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), $str); } -- cgit v1.2.3-24-g4f1b From 89338828264a6b50e0eb63c449a96f14f0f84076 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 12 Mar 2012 21:03:37 +0700 Subject: Path helper improvement --- system/helpers/path_helper.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 2eb85fefa..1b9bdae75 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -58,21 +58,15 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - if (function_exists('realpath') AND @realpath($path) !== FALSE) - { - $path = realpath($path); - } - - // Add a trailing slash - $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; + $realpath = realpath($path); - // Make sure the path exists - if ($check_existance == TRUE && ! is_dir($path)) + if ( ! $realpath) { - show_error('Not a valid path: '.$path); + return $check_existance ? show_error('Not a valid path: '.$path) : $path; } - return $path; + // Add a trailing slash, if this is a directory + return is_dir($realpath) ? rtrim($realpath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $realpath; } } -- cgit v1.2.3-24-g4f1b From 5fbaf27ac9da632b520457e91d9088e9aab6df89 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Mon, 12 Mar 2012 10:19:46 -0400 Subject: Changed space to tab in docblock. --- system/libraries/Table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 947aedd8f..649d50875 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -54,7 +54,7 @@ class CI_Table { /** * Set the template from the table config file if it exists * - * @param array $config (default: array()) + * @param array $config (default: array()) * @return void */ public function __construct($config = array()) -- cgit v1.2.3-24-g4f1b From 95bd1d1a5f5bdccfde53cc27d7d5c20991112643 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 16:22:28 +0200 Subject: Remove collation parameter from db_set_charset() (no longer needed) --- system/database/DB_driver.php | 6 +++--- system/database/drivers/mysql/mysql_driver.php | 3 +-- system/database/drivers/mysqli/mysqli_driver.php | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a04a65eeb..12cd3917c 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -165,7 +165,7 @@ class CI_DB_driver { } // Now we set the character set and that's all - return $this->db_set_charset($this->char_set, $this->dbcollat); + return $this->db_set_charset($this->char_set); } // -------------------------------------------------------------------- @@ -177,9 +177,9 @@ class CI_DB_driver { * @param string * @return bool */ - public function db_set_charset($charset, $collation = '') + public function db_set_charset($charset) { - if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset, $collation)) + if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset)) { log_message('error', 'Unable to set database connection charset: '.$charset); diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 071ce4327..ba646d226 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -144,10 +144,9 @@ class CI_DB_mysql_driver extends CI_DB { * Set client character set * * @param string - * @param string * @return bool */ - protected function _db_set_charset($charset, $collation) + protected function _db_set_charset($charset) { return @mysql_set_charset($charset, $this->conn_id); } diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index e84b8346d..f38b94c13 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -144,10 +144,9 @@ class CI_DB_mysqli_driver extends CI_DB { * Set client character set * * @param string - * @param string * @return bool */ - protected function _db_set_charset($charset, $collation) + protected function _db_set_charset($charset) { return @mysqli_set_charset($this->conn_id, $charset); } -- cgit v1.2.3-24-g4f1b From 802953234f0b7669333807aaa3f2318778cde187 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 16:29:16 +0200 Subject: Just some cleanup in the Table class --- system/libraries/Table.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index ceda6f323..99d001ce5 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * HTML Table Generating Class * @@ -49,18 +47,16 @@ class CI_Table { public $empty_cells = ''; public $function = FALSE; - // -------------------------------------------------------------------------- - /** * Set the template from the table config file if it exists - * + * * @param array $config (default: array()) * @return void */ public function __construct($config = array()) { - log_message('debug', "Table Class Initialized"); - + log_message('debug', 'Table Class Initialized'); + // initialize config foreach ($config as $key => $val) { -- cgit v1.2.3-24-g4f1b From 4a7dd98ffd1d21f2b14b9eefa70e6cae2f9aa92d Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 12 Mar 2012 21:33:55 +0700 Subject: Left the function_exists due some security restriction in some hosting environment --- system/helpers/path_helper.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 1b9bdae75..9c0af44c1 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.2.4 or newer + * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE * @@ -58,7 +58,14 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - $realpath = realpath($path); + if (function_exists('realpath')) + { + $realpath = realpath($path); + } + else + { + $realpath = (is_dir($path) or is_file($path)) ? $path : FALSE; + } if ( ! $realpath) { -- cgit v1.2.3-24-g4f1b From 7164cda9ab8aea8fc26aad21dd78c9f06839dec7 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 12 Mar 2012 21:36:04 +0700 Subject: Minimal PHP version annotation --- system/helpers/path_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 9c0af44c1..8c4730d73 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.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 a6fd531e348bd345bbbd06b7c5504090d9bd7ca4 Mon Sep 17 00:00:00 2001 From: Hamza Bhatti Date: Mon, 12 Mar 2012 14:36:33 +0400 Subject: Remove unused defines from CI_Utf8 --- system/core/Utf8.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index ba3567453..1d5dfc20d 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -57,26 +57,17 @@ class CI_Utf8 { && @ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled && $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8 ) - { - define('UTF8_ENABLED', TRUE); + { log_message('debug', 'UTF-8 Support Enabled'); // set internal encoding for multibyte string functions if necessary - // and set a flag so we don't have to repeatedly use extension_loaded() - // or function_exists() if (extension_loaded('mbstring')) { - define('MB_ENABLED', TRUE); mb_internal_encoding('UTF-8'); } - else - { - define('MB_ENABLED', FALSE); - } } else { - define('UTF8_ENABLED', FALSE); log_message('debug', 'UTF-8 Support Disabled'); } } -- cgit v1.2.3-24-g4f1b From 25cb81297c4458f80bee353fd645861a8a90ee33 Mon Sep 17 00:00:00 2001 From: Hamza Bhatti Date: Mon, 12 Mar 2012 15:31:13 +0400 Subject: Re-add UTF8_ENABLED constant --- system/core/Utf8.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 1d5dfc20d..21bac6078 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -57,7 +57,8 @@ class CI_Utf8 { && @ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled && $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8 ) - { + { + define('UTF8_ENABLED', TRUE); log_message('debug', 'UTF-8 Support Enabled'); // set internal encoding for multibyte string functions if necessary @@ -68,6 +69,7 @@ class CI_Utf8 { } else { + define('UTF8_ENABLED', FALSE); log_message('debug', 'UTF-8 Support Disabled'); } } -- cgit v1.2.3-24-g4f1b From 6da86c89f8b0ecb8bee11e6fa777dac7f6052236 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Mon, 12 Mar 2012 20:24:13 +0400 Subject: Re-add MB_ENABLED constant --- system/core/Utf8.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 21bac6078..0be42adb4 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -64,8 +64,13 @@ class CI_Utf8 { // set internal encoding for multibyte string functions if necessary if (extension_loaded('mbstring')) { + define('MB_ENABLED', TRUE) mb_internal_encoding('UTF-8'); } + else + { + define('MB_ENABLED', FALSE); + } } else { -- cgit v1.2.3-24-g4f1b From 5b9fd2deb29968fd5f7b039868d95ce9c1392de5 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Mon, 12 Mar 2012 20:26:59 +0400 Subject: Replace function_exists() checks with MB_ENABLED constant --- system/libraries/Form_validation.php | 8 ++++---- system/libraries/Trackback.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 826d94fb0..9491f354c 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -72,7 +72,7 @@ class CI_Form_validation { $this->CI->load->helper('form'); // Set the character encoding in MB. - if (function_exists('mb_internal_encoding')) + if (MB_ENABLED === TRUE) { mb_internal_encoding($this->CI->config->item('charset')); } @@ -950,7 +950,7 @@ class CI_Form_validation { return FALSE; } - if (function_exists('mb_strlen')) + if (MB_ENABLED === TRUE) { return ! (mb_strlen($str) < $val); } @@ -974,7 +974,7 @@ class CI_Form_validation { return FALSE; } - if (function_exists('mb_strlen')) + if (MB_ENABLED === TRUE) { return ! (mb_strlen($str) > $val); } @@ -998,7 +998,7 @@ class CI_Form_validation { return FALSE; } - if (function_exists('mb_strlen')) + if (MB_ENABLED === TRUE) { return (mb_strlen($str) == $val); } diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 3bea5f9b8..be1de6f3f 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -141,7 +141,7 @@ class CI_Trackback { $this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset'])); - if ($val != 'url' && function_exists('mb_convert_encoding')) + if ($val != 'url' && MB_ENABLED === TRUE) { $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']); } -- cgit v1.2.3-24-g4f1b From 39c87da04cca69aa0767afb1152f21ed4424db86 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Mon, 12 Mar 2012 21:26:38 +0400 Subject: Revert "Re-add MB_ENABLED constant" This reverts commit 6da86c89f8b0ecb8bee11e6fa777dac7f6052236. --- system/core/Utf8.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 0be42adb4..21bac6078 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -64,13 +64,8 @@ class CI_Utf8 { // set internal encoding for multibyte string functions if necessary if (extension_loaded('mbstring')) { - define('MB_ENABLED', TRUE) mb_internal_encoding('UTF-8'); } - else - { - define('MB_ENABLED', FALSE); - } } else { -- cgit v1.2.3-24-g4f1b From 3055e1fa227125383fb1fdbb3dd674aaaaf62184 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Mon, 12 Mar 2012 21:31:21 +0400 Subject: Revert "Re-add UTF8_ENABLED constant" This reverts commit 25cb81297c4458f80bee353fd645861a8a90ee33. --- system/core/Utf8.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 21bac6078..1d5dfc20d 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -57,8 +57,7 @@ class CI_Utf8 { && @ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled && $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8 ) - { - define('UTF8_ENABLED', TRUE); + { log_message('debug', 'UTF-8 Support Enabled'); // set internal encoding for multibyte string functions if necessary @@ -69,7 +68,6 @@ class CI_Utf8 { } else { - define('UTF8_ENABLED', FALSE); log_message('debug', 'UTF-8 Support Disabled'); } } -- cgit v1.2.3-24-g4f1b From 4efd1cf37fb5518ae81369f9066cea9b7246caee Mon Sep 17 00:00:00 2001 From: tiyowan Date: Mon, 12 Mar 2012 21:32:08 +0400 Subject: Revert "Remove unused defines from CI_Utf8" This reverts commit a6fd531e348bd345bbbd06b7c5504090d9bd7ca4. --- system/core/Utf8.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 1d5dfc20d..ba3567453 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -57,17 +57,26 @@ class CI_Utf8 { && @ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled && $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8 ) - { + { + define('UTF8_ENABLED', TRUE); log_message('debug', 'UTF-8 Support Enabled'); // set internal encoding for multibyte string functions if necessary + // and set a flag so we don't have to repeatedly use extension_loaded() + // or function_exists() if (extension_loaded('mbstring')) { + define('MB_ENABLED', TRUE); mb_internal_encoding('UTF-8'); } + else + { + define('MB_ENABLED', FALSE); + } } else { + define('UTF8_ENABLED', FALSE); log_message('debug', 'UTF-8 Support Disabled'); } } -- cgit v1.2.3-24-g4f1b From 6b535f51fcb94e0a645fda0d0356f4748076877e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 22:19:13 +0200 Subject: Fix some spaces and alignments in the new Wincache driver --- system/libraries/Cache/Cache.php | 21 ++++---- system/libraries/Cache/drivers/Cache_wincache.php | 60 +++++++++++------------ 2 files changed, 38 insertions(+), 43 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index b89e5ab6f..7642a5270 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -39,20 +39,17 @@ class CI_Cache extends CI_Driver_Library { protected $valid_drivers = array( - 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy', 'cache_wincache' - ); - - protected $_cache_path = NULL; // Path of cache files (if file-based cache) - protected $_adapter = 'dummy'; + 'cache_apc', + 'cache_file', + 'cache_memcached', + 'cache_dummy', + 'cache_wincache' + ); + + protected $_cache_path = NULL; // Path of cache files (if file-based cache) + protected $_adapter = 'dummy'; protected $_backup_driver; - // ------------------------------------------------------------------------ - - /** - * Constructor - * - * @param array - */ public function __construct($config = array()) { if ( ! empty($config)) diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index 8164b5a7b..df619d4e6 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 2.0 + * @since Version 3.0 * @filesource */ @@ -37,52 +37,51 @@ * @subpackage Libraries * @category Core * @author Mike Murkovic - * @link + * @link */ class CI_Cache_wincache extends CI_Driver { /** - * Get + * Get * - * Look for a value in the cache. If it exists, return the data + * Look for a value in the cache. If it exists, return the data, * if not, return FALSE * - * @param string - * @return mixed value that is stored/FALSE on failure + * @param string + * @return mixed value that is stored/FALSE on failure */ public function get($id) { $success = FALSE; $data = wincache_ucache_get($id, $success); - - //Success returned by reference from wincache_ucache_get + + // Success returned by reference from wincache_ucache_get() return ($success) ? $data : FALSE; } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + /** * Cache Save * - * @param string Unique Key - * @param mixed Data to store - * @param int Length of time (in seconds) to cache the data - * - * @return boolean true on success/false on failure + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { return wincache_ucache_set($id, $data, $ttl); } - + // ------------------------------------------------------------------------ /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @param boolean true on success/false on failure + * @param mixed unique identifier of the item in the cache + * @param bool true on success/false on failure */ public function delete($id) { @@ -94,7 +93,7 @@ class CI_Cache_wincache extends CI_Driver { /** * Clean the cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -106,11 +105,11 @@ class CI_Cache_wincache extends CI_Driver { /** * Cache Info * - * @return mixed array on success, false on failure + * @return mixed array on success, false on failure */ public function cache_info() { - return wincache_ucache_info(true); + return wincache_ucache_info(TRUE); } // ------------------------------------------------------------------------ @@ -118,12 +117,12 @@ class CI_Cache_wincache extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed array on success/false on failure + * @param mixed key to get cache metadata on + * @return mixed array on success/false on failure */ public function get_metadata($id) { - if ($stored = wincache_ucache_info(false, $id)) + if ($stored = wincache_ucache_info(FALSE, $id)) { $age = $stored['ucache_entries'][1]['age_seconds']; $ttl = $stored['ucache_entries'][1]['ttl_seconds']; @@ -136,7 +135,8 @@ class CI_Cache_wincache extends CI_Driver { 'ttl' => $ttl ); } - return false; + + return FALSE; } // ------------------------------------------------------------------------ @@ -145,23 +145,21 @@ class CI_Cache_wincache extends CI_Driver { * is_supported() * * Check to see if WinCache is available on this system, bail if it isn't. + * + * @return bool */ public function is_supported() { - if ( ! extension_loaded('wincache') ) + if ( ! extension_loaded('wincache')) { log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); return FALSE; } - + return TRUE; } - // ------------------------------------------------------------------------ - - } -// End Class /* End of file Cache_wincache.php */ /* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ -- cgit v1.2.3-24-g4f1b From fc49a657af78b0fb248cc666b162dc894e3e04ba Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Tue, 13 Mar 2012 03:27:58 +0700 Subject: Extra --- system/helpers/path_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 8c4730d73..e4fc6f157 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -58,13 +58,13 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - if (function_exists('realpath')) + if (function_exists('realpath') && @realpath($path) !== FALSE) { $realpath = realpath($path); } else { - $realpath = (is_dir($path) or is_file($path)) ? $path : FALSE; + $realpath = (is_dir($path) OR is_file($path)) ? $path : FALSE; } if ( ! $realpath) -- cgit v1.2.3-24-g4f1b From dbf4a5ad7b279b2833484e30f1168032cea9b7d3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 13 Mar 2012 12:08:59 +0200 Subject: Clean up the cookie helper --- system/helpers/cookie_helper.php | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'system') diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index b46f80540..38a2f78fc 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -1,13 +1,13 @@ -input->cookie($prefix.$index, $xss_clean); } } @@ -97,7 +86,7 @@ if ( ! function_exists('get_cookie')) * Delete a COOKIE * * @param mixed - * @param string the cookie domain. Usually: .yourdomain.com + * @param string the cookie domain. Usually: .yourdomain.com * @param string the cookie path * @param string the cookie prefix * @return void @@ -110,6 +99,5 @@ if ( ! function_exists('delete_cookie')) } } - /* End of file cookie_helper.php */ -/* Location: ./system/helpers/cookie_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/cookie_helper.php */ -- cgit v1.2.3-24-g4f1b From e5617335b5130718c43e5072ad003f677619d332 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 13 Mar 2012 12:22:17 +0200 Subject: Clean up the array helper --- system/helpers/array_helper.php | 47 ++++++++++------------------------------- 1 file changed, 11 insertions(+), 36 deletions(-) (limited to 'system') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index e5e32c48d..464d1d112 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -1,13 +1,13 @@ - Date: Tue, 13 Mar 2012 12:24:07 +0200 Subject: Remove access description line --- system/helpers/captcha_helper.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system') diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 9ae959fbe..7dc5b3eec 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -40,7 +40,6 @@ /** * Create CAPTCHA * - * @access public * @param array array of data for the CAPTCHA * @param string path to create the image in * @param string URL to the CAPTCHA image folder -- cgit v1.2.3-24-g4f1b From d153002858256c6f206c8877f4952ed075902f9e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 13 Mar 2012 12:31:13 +0200 Subject: Clean up the directory helper --- system/helpers/directory_helper.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php index 1d67e056d..d7ca13e85 100644 --- a/system/helpers/directory_helper.php +++ b/system/helpers/directory_helper.php @@ -1,13 +1,13 @@ - Date: Tue, 13 Mar 2012 13:13:43 +0200 Subject: Swtich _bind_params() from private to protected --- system/database/drivers/oci8/oci8_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 8e9ba9e5a..6842ec650 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -345,7 +345,7 @@ class CI_DB_oci8_driver extends CI_DB { * * @return void */ - private function _bind_params($params) + protected function _bind_params($params) { if ( ! is_array($params) OR ! is_resource($this->stmt_id)) { -- cgit v1.2.3-24-g4f1b From 5688d58688318cecaf9decdde014635f3a27760f Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Tue, 13 Mar 2012 19:29:29 +0100 Subject: Add support for buffer string email attachment. --- system/libraries/Email.php | 58 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 14 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f30fe40b6..aec4957de 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -83,6 +83,8 @@ class CI_Email { protected $_attach_name = array(); protected $_attach_type = array(); protected $_attach_disp = array(); + protected $_attach_source = array(); + protected $_attach_content = array(); protected $_protocols = array('mail', 'sendmail', 'smtp'); protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) protected $_bit_depths = array('7bit', '8bit'); @@ -171,6 +173,8 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); + $this->_attach_source = array(); + $this->_attach_content = array(); } return $this; @@ -411,6 +415,23 @@ class CI_Email { $this->_attach_name[] = array($filename, $newname); $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters + $this->_attach_source[] = 'file'; + return $this; + } + + /** + * Assign string attachments + * + * @param string + * @return object + */ + public function string_attach($str, $filename, $mime, $disposition = 'attachment') + { + $this->_attach_name[] = $filename; + $this->_attach_type[] = $mime; + $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters + $this->_attach_source[] = 'string'; + $this->_attach_content[] = $str; return $this; } @@ -1048,29 +1069,38 @@ class CI_Email { $filename = $this->_attach_name[$i][0]; $basename = (is_null($this->_attach_name[$i][1])) ? basename($filename) : $this->_attach_name[$i][1]; $ctype = $this->_attach_type[$i]; + $file_content = ''; - if ( ! file_exists($filename)) + if($this->_attach_source[$i] == 'file') { - $this->_set_error_message('lang:email_attachment_missing', $filename); - return FALSE; - } + if ( ! file_exists($filename)) + { + $this->_set_error_message('lang:email_attachment_missing', $filename); + return FALSE; + } + $file = filesize($filename) +1; + + if ( ! $fp = fopen($filename, FOPEN_READ)) + { + $this->_set_error_message('lang:email_attachment_unreadable', $filename); + return FALSE; + } + + $file_content = fread($fp, $file); + fclose($fp); + } + else + { + $file_content =& $this->_attach_content[$i]; + } $attachment[$z++] = "--".$this->_atc_boundary.$this->newline . "Content-type: ".$ctype."; " . "name=\"".$basename."\"".$this->newline . "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline . "Content-Transfer-Encoding: base64".$this->newline; - $file = filesize($filename) +1; - - if ( ! $fp = fopen($filename, FOPEN_READ)) - { - $this->_set_error_message('lang:email_attachment_unreadable', $filename); - return FALSE; - } - - $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file))); - fclose($fp); + $attachment[$z++] = chunk_split(base64_encode($file_content)); } $body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--"; -- cgit v1.2.3-24-g4f1b From ce707b4cafd64b95031690cf927584b1d60c7ad7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 14 Mar 2012 10:26:08 +0200 Subject: Further improve the path helper --- system/helpers/path_helper.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'system') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index e4fc6f157..c31f0bdc5 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Path Helpers * @@ -51,8 +49,8 @@ if ( ! function_exists('set_realpath')) { function set_realpath($path, $check_existance = FALSE) { - // Security check to make sure the path is NOT a URL. No remote file inclusion! - if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path)) + // Security check to make sure the path is NOT a URL. No remote file inclusion! + if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i', $path)) { show_error('The path you submitted must be a local server path, not a URL'); } @@ -60,20 +58,15 @@ if ( ! function_exists('set_realpath')) // Resolve the path if (function_exists('realpath') && @realpath($path) !== FALSE) { - $realpath = realpath($path); + $path = realpath($path); } - else - { - $realpath = (is_dir($path) OR is_file($path)) ? $path : FALSE; - } - - if ( ! $realpath) + elseif ($check_existance && ! is_dir($path) && ! is_file($path)) { - return $check_existance ? show_error('Not a valid path: '.$path) : $path; + show_error('Not a valid path: '.$path); } // Add a trailing slash, if this is a directory - return is_dir($realpath) ? rtrim($realpath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $realpath; + return is_dir($path) ? rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $path; } } -- cgit v1.2.3-24-g4f1b From 8d69aa166ca642cbbaed561878e22470720ecb78 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Wed, 14 Mar 2012 08:44:55 +0000 Subject: changed default value for $units to 7 --- system/helpers/date_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 2ad287b4a..9eea02561 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -164,7 +164,7 @@ if ( ! function_exists('standard_date')) */ if ( ! function_exists('timespan')) { - function timespan($seconds = 1, $time = '', $units = '') + function timespan($seconds = 1, $time = '', $units = 7) { $CI =& get_instance(); $CI->lang->load('date'); @@ -181,7 +181,7 @@ if ( ! function_exists('timespan')) if ( ! is_numeric($units)) { - $units = 999; + $units = 7; } $seconds = ($time <= $seconds) ? 1 : $time - $seconds; -- cgit v1.2.3-24-g4f1b From 597eb2178a0e51c105ea1d15717a9912450eb110 Mon Sep 17 00:00:00 2001 From: Roger Herbert Date: Wed, 14 Mar 2012 09:06:17 +0000 Subject: check array count for seconds unit too --- system/helpers/date_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 9eea02561..2cbfd5a92 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -255,7 +255,7 @@ if ( ! function_exists('timespan')) $seconds -= $minutes * 60; } - if ($str == '') + if (count($str) === 0) { $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); } -- cgit v1.2.3-24-g4f1b From c2acb23b5148182893583b495f451c7a28950c23 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Wed, 14 Mar 2012 21:24:00 +0400 Subject: Fix comment typo in Form_validation.php --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 9491f354c..3e0c72e84 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -101,7 +101,7 @@ class CI_Form_validation { return $this; } - // If an array was passed via the first parameter instead of indidual string + // If an array was passed via the first parameter instead of individual string // values we cycle through it and recursively call this function. if (is_array($field)) { -- cgit v1.2.3-24-g4f1b From 5a98a3dda56f6167f8241a7bc7d1c8784d98ccf9 Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Thu, 15 Mar 2012 12:00:44 +0100 Subject: Email class: move string_attach() to attach() and add documentation --- system/libraries/Email.php | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index aec4957de..df03eaaf6 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -83,7 +83,6 @@ class CI_Email { protected $_attach_name = array(); protected $_attach_type = array(); protected $_attach_disp = array(); - protected $_attach_source = array(); protected $_attach_content = array(); protected $_protocols = array('mail', 'sendmail', 'smtp'); protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) @@ -173,7 +172,6 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); - $this->_attach_source = array(); $this->_attach_content = array(); } @@ -410,27 +408,11 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $disposition = '', $newname = NULL) + public function attach($filename, $str = '', $mime = '', $disposition = '', $newname = NULL) { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); + $this->_attach_type[] = ($mime === '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters - $this->_attach_source[] = 'file'; - return $this; - } - - /** - * Assign string attachments - * - * @param string - * @return object - */ - public function string_attach($str, $filename, $mime, $disposition = 'attachment') - { - $this->_attach_name[] = $filename; - $this->_attach_type[] = $mime; - $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters - $this->_attach_source[] = 'string'; $this->_attach_content[] = $str; return $this; } @@ -1071,7 +1053,7 @@ class CI_Email { $ctype = $this->_attach_type[$i]; $file_content = ''; - if($this->_attach_source[$i] == 'file') + if ($this->_attach_content[$i] === '') { if ( ! file_exists($filename)) { -- cgit v1.2.3-24-g4f1b From df59c687a2243142e6da9d7b904523a1b91ca09b Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Thu, 15 Mar 2012 16:03:58 +0100 Subject: Email class: adjust documentation and make the code backward compatible --- system/libraries/Email.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index df03eaaf6..7320ea566 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -408,10 +408,10 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $str = '', $mime = '', $disposition = '', $newname = NULL) + public function attach($filename, $disposition = '', $str = '', $mime = '', $newname = NULL) { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = ($mime === '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; + $this->_attach_type[] = ($mime == '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters $this->_attach_content[] = $str; return $this; -- cgit v1.2.3-24-g4f1b From 865ce1e3a2466259996e52d764650e2144ae10c9 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sat, 17 Mar 2012 02:19:42 +0700 Subject: Spacing and replace array_key_exists --- system/database/drivers/pdo/pdo_result.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 213b5d670..6bc923e38 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -162,7 +162,7 @@ class CI_DB_pdo_result extends CI_DB_result { { if (strpos($this->result_id->queryString, 'PRAGMA') !== FALSE) { - foreach($this->result_array() as $field) + foreach ($this->result_array() as $field) { preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field['type'], $matches); @@ -197,7 +197,7 @@ class CI_DB_pdo_result extends CI_DB_result { else { $F->max_length = ($field['len'] > 255) ? NULL : (string) $field['len']; - $F->primary_key = (int) (array_key_exists('flags', $field) && in_array('primary_key', $field['flags'])); + $F->primary_key = (int) ( ! empty($field['flags']) && in_array('primary_key', $field['flags'])); } $data[] = $F; -- cgit v1.2.3-24-g4f1b From 4a80154b0bb28df04d407d3d3d83e112808b25d4 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 18 Mar 2012 01:00:36 +0700 Subject: Remove type casting --- system/database/drivers/pdo/pdo_result.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 6bc923e38..1c72216b1 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -196,7 +196,7 @@ class CI_DB_pdo_result extends CI_DB_result { } else { - $F->max_length = ($field['len'] > 255) ? NULL : (string) $field['len']; + $F->max_length = ($field['len'] > 255) ? 0 : $field['len']; $F->primary_key = (int) ( ! empty($field['flags']) && in_array('primary_key', $field['flags'])); } -- cgit v1.2.3-24-g4f1b From 4ad0fd86e8dc6dba74305dbb0c88c593b46a19a2 Mon Sep 17 00:00:00 2001 From: freewil Date: Tue, 13 Mar 2012 22:37:42 -0400 Subject: add support for httponly cookies --- system/core/Input.php | 13 +++++++++---- system/core/Security.php | 10 +++++++++- system/helpers/cookie_helper.php | 8 +++++--- system/libraries/Session.php | 18 ++++++++++-------- 4 files changed, 33 insertions(+), 16 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 901b4147e..6e6885992 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -228,7 +228,7 @@ class CI_Input { /** * Set cookie * - * Accepts six parameter, or you can submit an associative + * Accepts seven parameters, or you can submit an associative * array in the first parameter containing all the values. * * @param mixed @@ -238,14 +238,15 @@ class CI_Input { * @param string the cookie path * @param string the cookie prefix * @param bool true makes the cookie secure + * @param bool true makes the cookie accessible via http(s) only (no javascript) * @return void */ - public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) + public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE) { if (is_array($name)) { // always leave 'name' in last place, as the loop will break otherwise, due to $$item - foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item) + foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item) { if (isset($name[$item])) { @@ -270,6 +271,10 @@ class CI_Input { { $secure = config_item('cookie_secure'); } + if ($httponly == FALSE && config_item('cookie_httponly') != FALSE) + { + $httponly = config_item('cookie_httponly'); + } if ( ! is_numeric($expire)) { @@ -280,7 +285,7 @@ class CI_Input { $expire = ($expire > 0) ? time() + $expire : 0; } - setcookie($prefix.$name, $value, $expire, $path, $domain, $secure); + setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly); } // -------------------------------------------------------------------- diff --git a/system/core/Security.php b/system/core/Security.php index cd8a61028..ac39ce97b 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -196,7 +196,15 @@ class CI_Security { return FALSE; } - setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie); + setcookie( + $this->_csrf_cookie_name, + $this->_csrf_hash, + $expire, + config_item('cookie_path'), + config_item('cookie_domain'), + $secure_cookie, + config_item('cookie_httponly') + ); log_message('debug', 'CRSF cookie Set'); return $this; diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 38a2f78fc..ec8aa3250 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -40,7 +40,7 @@ /** * Set cookie * - * Accepts six parameter, or you can submit an associative + * Accepts seven parameters, or you can submit an associative * array in the first parameter containing all the values. * * @param mixed @@ -49,15 +49,17 @@ * @param string the cookie domain. Usually: .yourdomain.com * @param string the cookie path * @param string the cookie prefix + * @param bool true makes the cookie secure + * @param bool true makes the cookie accessible via http(s) only (no javascript) * @return void */ if ( ! function_exists('set_cookie')) { - function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) + function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE) { // Set the config file options $CI =& get_instance(); - $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); + $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly); } } diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 0b9d45b2a..0c8d46591 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -48,6 +48,7 @@ class CI_Session { public $cookie_path = ''; public $cookie_domain = ''; public $cookie_secure = FALSE; + public $cookie_httponly = FALSE; public $sess_time_to_update = 300; public $encryption_key = ''; public $flashdata_key = 'flash'; @@ -72,7 +73,7 @@ class CI_Session { // Set all the session preferences, which can either be set // manually via the $params array above or via the config file - foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) + foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) { $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); } @@ -666,13 +667,14 @@ class CI_Session { // Set the cookie setcookie( - $this->sess_cookie_name, - $cookie_data, - $expire, - $this->cookie_path, - $this->cookie_domain, - $this->cookie_secure - ); + $this->sess_cookie_name, + $cookie_data, + $expire, + $this->cookie_path, + $this->cookie_domain, + $this->cookie_secure, + $this->cookie_httponly + ); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 8840c96cc0608859ad4b5341c31db9bb1f833792 Mon Sep 17 00:00:00 2001 From: freewil Date: Sun, 18 Mar 2012 15:23:09 -0400 Subject: use php's hash() function for do_hash() helper --- system/helpers/security_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index e05e947a5..16dfb0de3 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -87,7 +87,7 @@ if ( ! function_exists('do_hash')) { function do_hash($str, $type = 'sha1') { - return ($type === 'sha1') ? sha1($str) : md5($str); + return hash($type, $str); } } -- cgit v1.2.3-24-g4f1b From 50bff7c06c177f580db956ef5df9a490141de5f6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Mar 2012 12:16:38 +0200 Subject: Fix possible error messages with do_hash() and alter a changelog entry --- system/helpers/security_helper.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 16dfb0de3..2f3df7834 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Security Helpers * @@ -42,7 +40,6 @@ /** * XSS Filtering * - * @access public * @param string * @param bool whether or not the content is an image file * @return string @@ -61,7 +58,6 @@ if ( ! function_exists('xss_clean')) /** * Sanitize Filename * - * @access public * @param string * @return string */ @@ -79,7 +75,6 @@ if ( ! function_exists('sanitize_filename')) /** * Hash encode a string * - * @access public * @param string * @return string */ @@ -87,6 +82,11 @@ if ( ! function_exists('do_hash')) { function do_hash($str, $type = 'sha1') { + if ( ! in_array($type, hash_algos())) + { + $type = 'md5'; + } + return hash($type, $str); } } @@ -96,7 +96,6 @@ if ( ! function_exists('do_hash')) /** * Strip Image Tags * - * @access public * @param string * @return string */ @@ -104,7 +103,7 @@ if ( ! function_exists('strip_image_tags')) { function strip_image_tags($str) { - return preg_replace(array("##", "##"), "\\1", $str); + return preg_replace(array('##', '##'), '\\1', $str); } } @@ -113,7 +112,6 @@ if ( ! function_exists('strip_image_tags')) /** * Convert PHP tags to entities * - * @access public * @param string * @return string */ -- cgit v1.2.3-24-g4f1b From 7eea3064af3be5dd0b526056211a510f90a40766 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Mar 2012 12:58:45 +0200 Subject: Apply strtolower() to hash support check in do_hash() --- system/helpers/security_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 2f3df7834..8c7adea46 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -82,7 +82,7 @@ if ( ! function_exists('do_hash')) { function do_hash($str, $type = 'sha1') { - if ( ! in_array($type, hash_algos())) + if ( ! in_array(strtolower($type), hash_algos())) { $type = 'md5'; } -- cgit v1.2.3-24-g4f1b From 992f17568dc59af9fcc243a19dd8fcafeeff7aaa Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Mar 2012 16:58:43 +0200 Subject: Switched MySQLi driver to use OOP --- system/database/drivers/mysqli/mysqli_driver.php | 29 ++++++++++++------------ system/database/drivers/mysqli/mysqli_result.php | 16 ++++++------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index f38b94c13..43e8ac756 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -72,8 +72,8 @@ class CI_DB_mysqli_driver extends CI_DB { public function db_connect() { return ($this->port != '') - ? @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port) - : @mysqli_connect($this->hostname, $this->username, $this->password, $this->database); + ? @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port) + : @new mysqli($this->hostname, $this->username, $this->password, $this->database); } // -------------------------------------------------------------------- @@ -92,8 +92,8 @@ class CI_DB_mysqli_driver extends CI_DB { } return ($this->port != '') - ? @mysqli_connect('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port) - : @mysqli_connect('p:'.$this->hostname, $this->username, $this->password, $this->database); + ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port) + : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database); } // -------------------------------------------------------------------- @@ -108,7 +108,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function reconnect() { - if (mysqli_ping($this->conn_id) === FALSE) + if ($this->conn_id !== FALSE && $this->conn_id->ping() === FALSE) { $this->conn_id = FALSE; } @@ -129,7 +129,7 @@ class CI_DB_mysqli_driver extends CI_DB { $database = $this->database; } - if (@mysqli_select_db($this->conn_id, $database)) + if (@$this->conn_id->select_db($database)) { $this->database = $database; return TRUE; @@ -148,7 +148,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ protected function _db_set_charset($charset) { - return @mysqli_set_charset($this->conn_id, $charset); + return @$this->conn_id->set_charset($charset); } // -------------------------------------------------------------------- @@ -162,7 +162,7 @@ class CI_DB_mysqli_driver extends CI_DB { { return isset($this->data_cache['version']) ? $this->data_cache['version'] - : $this->data_cache['version'] = @mysqli_get_server_info($this->conn_id); + : $this->data_cache['version'] = $this->conn_id->server_info; } // -------------------------------------------------------------------- @@ -175,7 +175,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ protected function _execute($sql) { - return @mysqli_query($this->conn_id, $this->_prep_query($sql)); + return @$this->conn_id->query($this->_prep_query($sql)); } // -------------------------------------------------------------------- @@ -286,7 +286,7 @@ class CI_DB_mysqli_driver extends CI_DB { return $str; } - $str = is_object($this->conn_id) ? mysqli_real_escape_string($this->conn_id, $str) : addslashes($str); + $str = is_object($this->conn_id) ? $this->conn_id->real_escape_string($str) : addslashes($str); // escape LIKE condition wildcards if ($like === TRUE) @@ -306,7 +306,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function affected_rows() { - return @mysqli_affected_rows($this->conn_id); + return $this->conn_id->affected_rows; } // -------------------------------------------------------------------- @@ -318,7 +318,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function insert_id() { - return @mysqli_insert_id($this->conn_id); + return $this->conn_id->insert_id; } // -------------------------------------------------------------------- @@ -434,7 +434,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function error() { - return array('code' => mysqli_errno($this->conn_id), 'message' => mysqli_error($this->conn_id)); + return array('code' => $this->conn_id->errno, 'message' => $this->conn_id->error); } // -------------------------------------------------------------------- @@ -691,7 +691,8 @@ class CI_DB_mysqli_driver extends CI_DB { */ protected function _close($conn_id) { - @mysqli_close($conn_id); + $this->conn_id->close(); + $this->conn_id = FALSE; } } diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index f135f4d46..dc7d9a793 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -43,7 +43,7 @@ class CI_DB_mysqli_result extends CI_DB_result { */ public function num_rows() { - return @mysqli_num_rows($this->result_id); + return $this->result_id->num_rows; } // -------------------------------------------------------------------- @@ -55,7 +55,7 @@ class CI_DB_mysqli_result extends CI_DB_result { */ public function num_fields() { - return @mysqli_num_fields($this->result_id); + return $this->result_id->field_count; } // -------------------------------------------------------------------- @@ -70,7 +70,7 @@ class CI_DB_mysqli_result extends CI_DB_result { public function list_fields() { $field_names = array(); - while ($field = mysqli_fetch_field($this->result_id)) + while ($field = $this->result_id->fetch_field()) { $field_names[] = $field->name; } @@ -90,7 +90,7 @@ class CI_DB_mysqli_result extends CI_DB_result { public function field_data() { $retval = array(); - $field_data = mysqli_fetch_fields($this->result_id); + $field_data = $this->result_id->fetch_fields(); for ($i = 0, $c = count($field_data); $i < $c; $i++) { $retval[$i] = new stdClass(); @@ -115,7 +115,7 @@ class CI_DB_mysqli_result extends CI_DB_result { { if (is_object($this->result_id)) { - mysqli_free_result($this->result_id); + $this->result_id->free(); $this->result_id = FALSE; } } @@ -133,7 +133,7 @@ class CI_DB_mysqli_result extends CI_DB_result { */ protected function _data_seek($n = 0) { - return mysqli_data_seek($this->result_id, $n); + return $this->result_id->data_seek($n); } // -------------------------------------------------------------------- @@ -147,7 +147,7 @@ class CI_DB_mysqli_result extends CI_DB_result { */ protected function _fetch_assoc() { - return mysqli_fetch_assoc($this->result_id); + return $this->result_id->fetch_assoc(); } // -------------------------------------------------------------------- @@ -161,7 +161,7 @@ class CI_DB_mysqli_result extends CI_DB_result { */ protected function _fetch_object() { - return mysqli_fetch_object($this->result_id); + return $this->result_id->fetch_object(); } } -- cgit v1.2.3-24-g4f1b From 7eeda537a1fa8dc3a60bbdb88a7e473cc909f590 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 16:01:55 -0400 Subject: Made database parent classes and methods abstract --- system/database/DB_active_rec.php | 2 +- system/database/DB_driver.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 35164a79c..89369f190 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -38,7 +38,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -class CI_DB_active_record extends CI_DB_driver { +abstract class CI_DB_active_record extends CI_DB_driver { protected $return_delete_sql = FALSE; protected $reset_delete_data = FALSE; diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index bcff43392..79b7285bd 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -38,7 +38,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -class CI_DB_driver { +abstract class CI_DB_driver { public $dsn; public $username; @@ -1357,9 +1357,7 @@ class CI_DB_driver { * * @return void */ - protected function _reset_select() - { - } + abstract protected function _reset_select(); } -- 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_forge.php | 2 +- system/database/DB_result.php | 2 +- system/database/DB_utility.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index fe2a67728..192b78fa6 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -34,7 +34,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -class CI_DB_forge { +abstract class CI_DB_forge { public $fields = array(); public $keys = array(); diff --git a/system/database/DB_result.php b/system/database/DB_result.php index c3cdd24ff..d0205e0fd 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -36,7 +36,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -class CI_DB_result { +abstract class CI_DB_result { public $conn_id = NULL; public $result_id = NULL; 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 d2ff0bc1336e106e4b45abe7ee176bf6b9496b6e Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 16:52:10 -0400 Subject: Removed pointless _prep_sql methods --- system/database/DB_driver.php | 2 +- system/database/drivers/cubrid/cubrid_driver.php | 18 ------------------ .../database/drivers/interbase/interbase_driver.php | 16 ---------------- system/database/drivers/mssql/mssql_driver.php | 17 ----------------- system/database/drivers/oci8/oci8_driver.php | 20 ++------------------ system/database/drivers/odbc/odbc_driver.php | 17 ----------------- system/database/drivers/postgre/postgre_driver.php | 17 ----------------- system/database/drivers/sqlite/sqlite_driver.php | 19 ------------------- system/database/drivers/sqlsrv/sqlsrv_driver.php | 17 ----------------- 9 files changed, 3 insertions(+), 140 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 79b7285bd..42b1b35aa 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1362,4 +1362,4 @@ abstract class CI_DB_driver { } /* End of file DB_driver.php */ -/* Location: ./system/database/DB_driver.php */ +/* Location: ./system/database/DB_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 244707395..32bd8a8b2 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -178,29 +178,11 @@ class CI_DB_cubrid_driver extends CI_DB { */ function _execute($sql) { - $sql = $this->_prep_query($sql); return @cubrid_query($sql, $this->conn_id); } // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @access private called by execute() - * @param string an SQL query - * @return string - */ - function _prep_query($sql) - { - // No need to prepare - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index a9a647202..4af5b57ed 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -148,27 +148,11 @@ class CI_DB_interbase_driver extends CI_DB { */ protected function _execute($sql) { - $sql = $this->_prep_query($sql); return @ibase_query($this->conn_id, $sql); } // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @param string an SQL query - * @return string - */ - protected function _prep_query($sql) - { - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index b6b64cc44..a93ac57fe 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -146,28 +146,11 @@ class CI_DB_mssql_driver extends CI_DB { */ function _execute($sql) { - $sql = $this->_prep_query($sql); return @mssql_query($sql, $this->conn_id); } // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @access private called by execute() - * @param string an SQL query - * @return string - */ - function _prep_query($sql) - { - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 070d58a34..8d7040618 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -180,26 +180,10 @@ class CI_DB_oci8_driver extends CI_DB { { if ( ! is_resource($this->stmt_id)) { - $this->stmt_id = oci_parse($this->conn_id, $this->_prep_query($sql)); + $this->stmt_id = oci_parse($this->conn_id, $sql); } } - - // -------------------------------------------------------------------- - - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @access private called by execute() - * @param string an SQL query - * @return string - */ - private function _prep_query($sql) - { - return $sql; - } - + // -------------------------------------------------------------------- /** diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index acc2838e3..58da07818 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -132,28 +132,11 @@ class CI_DB_odbc_driver extends CI_DB { */ function _execute($sql) { - $sql = $this->_prep_query($sql); return @odbc_exec($this->conn_id, $sql); } // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @access private called by execute() - * @param string an SQL query - * @return string - */ - function _prep_query($sql) - { - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 5d22af2e6..fad9539ff 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -197,28 +197,11 @@ class CI_DB_postgre_driver extends CI_DB { */ function _execute($sql) { - $sql = $this->_prep_query($sql); return @pg_query($this->conn_id, $sql); } // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @access private called by execute() - * @param string an SQL query - * @return string - */ - function _prep_query($sql) - { - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 55d9bfdb8..1870e73b7 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -27,8 +27,6 @@ // ------------------------------------------------------------------------ - - /** * SQLite Database Adapter Class * @@ -163,28 +161,11 @@ class CI_DB_sqlite_driver extends CI_DB { */ function _execute($sql) { - $sql = $this->_prep_query($sql); return @sqlite_query($this->conn_id, $sql); } // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @access private called by execute() - * @param string an SQL query - * @return string - */ - function _prep_query($sql) - { - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 5e920cbe8..ea9f9483b 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -152,7 +152,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ function _execute($sql) { - $sql = $this->_prep_query($sql); return sqlsrv_query($this->conn_id, $sql, null, array( 'Scrollable' => SQLSRV_CURSOR_STATIC, 'SendStreamParamsAtExec' => true @@ -161,22 +160,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @access private called by execute() - * @param string an SQL query - * @return string - */ - function _prep_query($sql) - { - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * -- cgit v1.2.3-24-g4f1b From 70b21018b4941414c0041900f26c637763e19cfe Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 17:33:05 -0400 Subject: Added access modifiers to CUBRID driver --- system/database/drivers/cubrid/cubrid_driver.php | 87 +++++++++--------------- 1 file changed, 31 insertions(+), 56 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 32bd8a8b2..cc9f23d9e 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -66,10 +66,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect() + protected function db_connect() { // If no port is defined by the user, use the default value if ($this->port == '') @@ -106,13 +105,12 @@ class CI_DB_cubrid_driver extends CI_DB { * file by setting the CCI_PCONNECT parameter to ON. In that case, all * connections established between the client application and the * server will become persistent. This is calling the same - * @cubrid_connect function will establish persisten connection + * @cubrid_connect public function will establish persisten connection * considering that the CCI_PCONNECT is ON. * - * @access private called by the base class * @return resource */ - function db_pconnect() + protected function db_pconnect() { return $this->db_connect(); } @@ -125,10 +123,9 @@ class CI_DB_cubrid_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { if (cubrid_ping($this->conn_id) === FALSE) { @@ -141,10 +138,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { // In CUBRID there is no need to select a database as the database // is chosen at the connection time. @@ -172,11 +168,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return @cubrid_query($sql, $this->conn_id); } @@ -186,10 +181,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -220,10 +214,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -251,10 +244,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -282,12 +274,11 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -324,7 +315,7 @@ class CI_DB_cubrid_driver extends CI_DB { * * @return int */ - public function affected_rows() + public public function affected_rows() { return @cubrid_affected_rows(); } @@ -334,10 +325,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Insert ID * - * @access public * @return integer */ - function insert_id() + public function insert_id() { return @cubrid_insert_id($this->conn_id); } @@ -350,11 +340,10 @@ class CI_DB_cubrid_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified table * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -379,11 +368,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SHOW TABLES"; @@ -402,11 +390,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + public function _list_columns($table = '') { return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); } @@ -418,11 +405,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -437,7 +423,7 @@ class CI_DB_cubrid_driver extends CI_DB { * * @return array */ - public function error() + public public function error() { return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id)); } @@ -445,13 +431,12 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This function escapes column and table names + * This public function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + protected function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -487,14 +472,13 @@ class CI_DB_cubrid_driver extends CI_DB { /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -511,13 +495,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; } @@ -530,13 +513,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific replace string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _replace($table, $keys, $values) + public function _replace($table, $keys, $values) { return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; } @@ -548,13 +530,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert_batch($table, $keys, $values) + public function _insert_batch($table, $keys, $values) { return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values); } @@ -567,7 +548,6 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -575,7 +555,7 @@ class CI_DB_cubrid_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -603,13 +583,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific batch update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause * @return string */ - function _update_batch($table, $values, $index, $where = NULL) + public function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; @@ -656,13 +635,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return "TRUNCATE ".$table; } @@ -674,13 +652,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -708,13 +685,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -733,11 +709,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @cubrid_close($conn_id); } -- cgit v1.2.3-24-g4f1b From f83f0d5448aadcf76fbdac363d0fe7ea811ca9bf Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 17:38:30 -0400 Subject: Added access modifiers to the rest of the Cubrid classes --- system/database/drivers/cubrid/cubrid_forge.php | 21 +++++++-------------- system/database/drivers/cubrid/cubrid_result.php | 23 ++++++++--------------- system/database/drivers/cubrid/cubrid_utility.php | 8 ++++---- 3 files changed, 19 insertions(+), 33 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 7d606ea36..6bfc7c28f 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -39,11 +39,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Create database * - * @access private * @param string the database name * @return bool */ - function _create_database($name) + protected function _create_database($name) { // CUBRID does not allow to create a database in SQL. The GUI tools // have to be used for this purpose. @@ -55,11 +54,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + protected function _drop_database($name) { // CUBRID does not allow to drop a database in SQL. The GUI tools // have to be used for this purpose. @@ -71,11 +69,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Process Fields * - * @access private * @param mixed the fields * @return string */ - function _process_fields($fields) + protected function _process_fields($fields) { $current_field_count = 0; $sql = ''; @@ -172,7 +169,6 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param mixed the fields * @param mixed primary key(s) @@ -180,7 +176,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -232,10 +228,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return string */ - function _drop_table($table) + protected function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table); } @@ -248,14 +243,13 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param array fields * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $fields, $after_field = '') + protected function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -282,12 +276,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php index a7eeb8a39..c7a7632aa 100644 --- a/system/database/drivers/cubrid/cubrid_result.php +++ b/system/database/drivers/cubrid/cubrid_result.php @@ -41,10 +41,9 @@ class CI_DB_cubrid_result extends CI_DB_result { /** * Number of rows in the result set * - * @access public * @return integer */ - function num_rows() + public function num_rows() { return @cubrid_num_rows($this->result_id); } @@ -54,10 +53,9 @@ class CI_DB_cubrid_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ - function num_fields() + public function num_fields() { return @cubrid_num_fields($this->result_id); } @@ -69,10 +67,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { return cubrid_column_names($this->result_id); } @@ -84,10 +81,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); @@ -149,7 +145,7 @@ class CI_DB_cubrid_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { if(is_resource($this->result_id) || get_resource_type($this->result_id) == "Unknown" && @@ -169,10 +165,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return cubrid_data_seek($this->result_id, $n); } @@ -184,10 +179,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return cubrid_fetch_assoc($this->result_id); } @@ -199,10 +193,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return cubrid_fetch_object($this->result_id); } diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php index a13c0a5e4..de28e6335 100644 --- a/system/database/drivers/cubrid/cubrid_utility.php +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -42,7 +42,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @access private * @return array */ - function _list_databases() + protected function _list_databases() { // CUBRID does not allow to see the list of all databases on the // server. It is the way its architecture is designed. Every @@ -71,7 +71,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Optimize%20Database */ - function _optimize_table($table) + protected function _optimize_table($table) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table optimization can be performed using CUBRID Manager @@ -91,7 +91,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency */ - function _repair_table($table) + protected function _repair_table($table) { // Not supported in CUBRID as of version 8.4.0. Database or // table consistency can be checked using CUBRID Manager @@ -107,7 +107,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - function _backup($params = array()) + protected function _backup($params = array()) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table backup can be performed using CUBRID Manager -- cgit v1.2.3-24-g4f1b From ba1ebbefa9c5d225fa28c76dac276e6120263a25 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 17:48:46 -0400 Subject: Added access modifiers for MSSQL driver --- system/database/drivers/mssql/mssql_driver.php | 81 +++++++++---------------- system/database/drivers/mssql/mssql_forge.php | 20 +++--- system/database/drivers/mssql/mssql_result.php | 24 +++----- system/database/drivers/mssql/mssql_utility.php | 12 ++-- 4 files changed, 47 insertions(+), 90 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index a93ac57fe..9448f052c 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -62,10 +62,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect() + protected function db_connect() { if ($this->port != '') { @@ -80,10 +79,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + protected function db_pconnect() { if ($this->port != '') { @@ -101,10 +99,9 @@ class CI_DB_mssql_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in MSSQL } @@ -140,11 +137,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return @mssql_query($sql, $this->conn_id); } @@ -154,10 +150,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -184,10 +179,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -209,10 +203,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -234,12 +227,11 @@ class CI_DB_mssql_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -272,10 +264,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return @mssql_rows_affected($this->conn_id); } @@ -287,10 +278,9 @@ class CI_DB_mssql_driver extends CI_DB { * * Returns the last id created in the Identity column. * - * @access public * @return integer */ - function insert_id() + public function insert_id() { $ver = self::_parse_major_version($this->version()); $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id"); @@ -307,11 +297,10 @@ class CI_DB_mssql_driver extends CI_DB { * Grabs the major version number from the * database server version string passed in. * - * @access private * @param string $version * @return int16 major version number */ - function _parse_major_version($version) + protected function _parse_major_version($version) { preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); return $ver_info[1]; // return the major version b/c that's all we're interested in. @@ -324,7 +313,7 @@ class CI_DB_mssql_driver extends CI_DB { * * @return string */ - protected function _version() + protected public function _version() { return 'SELECT @@VERSION AS ver'; } @@ -337,11 +326,10 @@ class CI_DB_mssql_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -366,11 +354,10 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; @@ -391,11 +378,10 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access private * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'"; } @@ -407,11 +393,10 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { return "SELECT TOP 1 * FROM ".$table; } @@ -438,13 +423,12 @@ class CI_DB_mssql_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This function escapes column and table names + * This public function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + protected function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -480,14 +464,13 @@ class CI_DB_mssql_driver extends CI_DB { /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -504,13 +487,12 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -522,7 +504,6 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -530,7 +511,7 @@ class CI_DB_mssql_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -558,13 +539,12 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return "TRUNCATE ".$table; } @@ -576,13 +556,12 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -610,13 +589,12 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { $i = $limit + $offset; @@ -628,18 +606,15 @@ class CI_DB_mssql_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @mssql_close($conn_id); } } - - /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index 4a8089bb1..500dd9845 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -39,11 +39,10 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Create database * - * @access private * @param string the database name * @return bool */ - function _create_database($name) + protected function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -53,11 +52,10 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + protected function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -67,10 +65,9 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return bool */ - function _drop_table($table) + protected function _drop_table($table) { return "DROP TABLE ".$this->db->_escape_identifiers($table); } @@ -80,7 +77,6 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -88,7 +84,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -190,7 +186,6 @@ class CI_DB_mssql_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -200,7 +195,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -242,12 +237,11 @@ class CI_DB_mssql_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); @@ -256,4 +250,4 @@ class CI_DB_mssql_forge extends CI_DB_forge { } /* End of file mssql_forge.php */ -/* Location: ./system/database/drivers/mssql/mssql_forge.php */ +/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index b205ce2d1..ff899406c 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -41,10 +41,9 @@ class CI_DB_mssql_result extends CI_DB_result { /** * Number of rows in the result set * - * @access public * @return integer */ - function num_rows() + public function num_rows() { return @mssql_num_rows($this->result_id); } @@ -54,10 +53,9 @@ class CI_DB_mssql_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ - function num_fields() + public function num_fields() { return @mssql_num_fields($this->result_id); } @@ -69,10 +67,9 @@ class CI_DB_mssql_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); while ($field = mssql_fetch_field($this->result_id)) @@ -90,10 +87,9 @@ class CI_DB_mssql_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); while ($field = mssql_fetch_field($this->result_id)) @@ -118,7 +114,7 @@ class CI_DB_mssql_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { if (is_resource($this->result_id)) { @@ -136,10 +132,9 @@ class CI_DB_mssql_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return mssql_data_seek($this->result_id, $n); } @@ -151,10 +146,9 @@ class CI_DB_mssql_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return mssql_fetch_assoc($this->result_id); } @@ -166,16 +160,14 @@ class CI_DB_mssql_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return mssql_fetch_object($this->result_id); } } - /* End of file mssql_result.php */ /* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index 28f34b999..e64874132 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -39,10 +39,9 @@ class CI_DB_mssql_utility extends CI_DB_utility { /** * List databases * - * @access private * @return bool */ - function _list_databases() + protected function _list_databases() { return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases } @@ -54,11 +53,10 @@ class CI_DB_mssql_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * - * @access private * @param string the table name * @return object */ - function _optimize_table($table) + protected function _optimize_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -70,11 +68,10 @@ class CI_DB_mssql_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * - * @access private * @param string the table name * @return object */ - function _repair_table($table) + protected function _repair_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -84,11 +81,10 @@ class CI_DB_mssql_utility extends CI_DB_utility { /** * MSSQL Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 9f86f5cddea54e7fedf4be89d1d1cc90d1564488 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 17:53:37 -0400 Subject: Oci8 access modifiers --- system/database/drivers/oci8/oci8_driver.php | 26 ++++++++++++-------------- system/database/drivers/oci8/oci8_forge.php | 17 ++++++----------- system/database/drivers/oci8/oci8_result.php | 3 +-- system/database/drivers/oci8/oci8_utility.php | 12 ++++-------- 4 files changed, 23 insertions(+), 35 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 8d7040618..e7b744bd3 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -53,33 +53,33 @@ class CI_DB_oci8_driver extends CI_DB { - var $dbdriver = 'oci8'; + public $dbdriver = 'oci8'; // The character used for excaping - var $_escape_char = '"'; + public $_escape_char = '"'; // clause and character used for LIKE escape sequences - var $_like_escape_str = " escape '%s' "; - var $_like_escape_chr = '!'; + public $_like_escape_str = " escape '%s' "; + public $_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. */ - var $_count_string = "SELECT COUNT(1) AS "; - var $_random_keyword = ' ASC'; // not currently supported + public $_count_string = "SELECT COUNT(1) AS "; + public $_random_keyword = ' ASC'; // not currently supported // Set "auto commit" by default - var $_commit = OCI_COMMIT_ON_SUCCESS; + public $_commit = OCI_COMMIT_ON_SUCCESS; // need to track statement id and cursor id - var $stmt_id; - var $curs_id; + public $stmt_id; + public $curs_id; // if we use a limit, we will add a field that will // throw off num_fields later - var $limit_used; + public $limit_used; /** * Non-persistent database connection @@ -214,7 +214,7 @@ class CI_DB_oci8_driver extends CI_DB { * KEY OPTIONAL NOTES * name no the name of the parameter should be in : format * value no the value of the parameter. If this is an OUT or IN OUT parameter, - * this should be a reference to a variable + * this should be a reference to a publiciable * type yes the type of the parameter * length yes the max size of the parameter */ @@ -781,7 +781,5 @@ class CI_DB_oci8_driver extends CI_DB { } - - /* End of file oci8_driver.php */ -/* Location: ./system/database/drivers/oci8/oci8_driver.php */ +/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 7fcc8094d..f9a90ff0a 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -39,11 +39,10 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Create database * - * @access public * @param string the database name * @return bool */ - function _create_database($name) + public function _create_database($name) { return FALSE; } @@ -53,11 +52,10 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + protected function _drop_database($name) { return FALSE; } @@ -144,10 +142,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return bool */ - function _drop_table($table) + protected function _drop_table($table) { return FALSE; } @@ -160,7 +157,6 @@ class CI_DB_oci8_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -170,7 +166,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -212,12 +208,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -225,4 +220,4 @@ class CI_DB_oci8_forge extends CI_DB_forge { } /* End of file oci8_forge.php */ -/* Location: ./system/database/drivers/oci8/oci8_forge.php */ +/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 6f1b8b4c1..a14e32eec 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -235,6 +235,5 @@ class CI_DB_oci8_result extends CI_DB_result { } - /* End of file oci8_result.php */ -/* Location: ./system/database/drivers/oci8/oci8_result.php */ +/* Location: ./system/database/drivers/oci8/oci8_result.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index 62dfb2f3c..f4863c0db 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -39,10 +39,9 @@ class CI_DB_oci8_utility extends CI_DB_utility { /** * List databases * - * @access private * @return bool */ - function _list_databases() + protected function _list_databases() { return FALSE; } @@ -54,11 +53,10 @@ class CI_DB_oci8_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * - * @access private * @param string the table name * @return object */ - function _optimize_table($table) + protected function _optimize_table($table) { return FALSE; // Is this supported in Oracle? } @@ -70,11 +68,10 @@ class CI_DB_oci8_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * - * @access private * @param string the table name * @return object */ - function _repair_table($table) + protected function _repair_table($table) { return FALSE; // Is this supported in Oracle? } @@ -84,11 +81,10 @@ class CI_DB_oci8_utility extends CI_DB_utility { /** * Oracle Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 142ca8e565b722b758b5ef88c888891d04da8700 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 18:00:35 -0400 Subject: ODBC access modifiers --- system/database/drivers/odbc/odbc_driver.php | 96 +++++++++++---------------- system/database/drivers/odbc/odbc_forge.php | 20 ++---- system/database/drivers/odbc/odbc_result.php | 19 ++---- system/database/drivers/odbc/odbc_utility.php | 12 ++-- 4 files changed, 55 insertions(+), 92 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 58da07818..78acd2ce9 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -48,32 +48,35 @@ class CI_DB_odbc_driver extends CI_DB { var $_escape_char = ''; // clause and character used for LIKE escape sequences - var $_like_escape_str = " {escape '%s'} "; - var $_like_escape_chr = '!'; + protected $_like_escape_str = " {escape '%s'} "; + 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. + * used for the count_all() and count_all_results() public functions. */ - var $_count_string = "SELECT COUNT(*) AS "; - var $_random_keyword; + protected $_count_string = "SELECT COUNT(*) AS "; + protected $_random_keyword; - - function __construct($params) + /** + * Constructor, to define random keyword + */ + public function __construct($params) { parent::__construct($params); $this->_random_keyword = ' RND('.time().')'; // database specific random keyword } + + // -------------------------------------------------------------------------- /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect() + protected function db_connect() { return @odbc_connect($this->hostname, $this->username, $this->password); } @@ -83,10 +86,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + protected function db_pconnect() { return @odbc_pconnect($this->hostname, $this->username, $this->password); } @@ -99,10 +101,9 @@ class CI_DB_odbc_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in odbc } @@ -112,10 +113,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + protected function db_select() { // Not needed for ODBC return TRUE; @@ -126,11 +126,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return @odbc_exec($this->conn_id, $sql); } @@ -140,10 +139,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -169,10 +167,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -195,10 +192,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -221,12 +217,11 @@ class CI_DB_odbc_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -257,10 +252,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return @odbc_num_rows($this->conn_id); } @@ -285,11 +279,10 @@ class CI_DB_odbc_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -315,11 +308,10 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SHOW TABLES FROM `".$this->database."`"; @@ -339,11 +331,10 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + public function _list_columns($table = '') { return "SHOW COLUMNS FROM ".$table; } @@ -355,11 +346,10 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { return "SELECT TOP 1 FROM ".$table; } @@ -384,13 +374,12 @@ class CI_DB_odbc_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This function escapes column and table names + * This public function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + protected function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -426,14 +415,13 @@ class CI_DB_odbc_driver extends CI_DB { /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -450,13 +438,12 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -468,7 +455,6 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -476,7 +462,7 @@ class CI_DB_odbc_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -504,13 +490,12 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return $this->_delete($table); } @@ -522,13 +507,12 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -556,13 +540,12 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { // Does ODBC doesn't use the LIMIT clause? return $sql; @@ -573,19 +556,14 @@ class CI_DB_odbc_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @odbc_close($conn_id); } - - } - - /* End of file odbc_driver.php */ -/* Location: ./system/database/drivers/odbc/odbc_driver.php */ +/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index acc2cadee..121c09606 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -39,11 +39,10 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Create database * - * @access private * @param string the database name * @return bool */ - function _create_database() + protected function _create_database() { // ODBC has no "create database" command since it's // designed to connect to an existing database @@ -59,11 +58,10 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + protected function _drop_database($name) { // ODBC has no "drop database" command since it's // designed to connect to an existing database @@ -79,7 +77,6 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -87,7 +84,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -186,10 +183,9 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return bool */ - function _drop_table($table) + protected function _drop_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -207,7 +203,6 @@ class CI_DB_odbc_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -217,7 +212,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -260,12 +255,11 @@ class CI_DB_odbc_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -273,4 +267,4 @@ class CI_DB_odbc_forge extends CI_DB_forge { } /* End of file odbc_forge.php */ -/* Location: ./system/database/drivers/odbc/odbc_forge.php */ +/* Location: ./system/database/drivers/odbc/odbc_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index d19fa247e..0b74871e0 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -130,7 +130,7 @@ class CI_DB_odbc_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { if (is_resource($this->result_id)) { @@ -148,10 +148,9 @@ class CI_DB_odbc_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return FALSE; } @@ -163,10 +162,9 @@ class CI_DB_odbc_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { if (function_exists('odbc_fetch_object')) { @@ -185,10 +183,9 @@ class CI_DB_odbc_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { if (function_exists('odbc_fetch_object')) { @@ -207,10 +204,9 @@ class CI_DB_odbc_result extends CI_DB_result { * subsititutes the odbc_fetch_object function when * not available (odbc_fetch_object requires unixODBC) * - * @access private * @return object */ - function _odbc_fetch_object(& $odbc_result) { + protected function _odbc_fetch_object(& $odbc_result) { $rs = array(); $rs_obj = FALSE; if (odbc_fetch_into($odbc_result, $rs)) { @@ -229,10 +225,9 @@ class CI_DB_odbc_result extends CI_DB_result { * subsititutes the odbc_fetch_array function when * not available (odbc_fetch_array requires unixODBC) * - * @access private * @return array */ - function _odbc_fetch_array(& $odbc_result) { + protected function _odbc_fetch_array(& $odbc_result) { $rs = array(); $rs_assoc = FALSE; if (odbc_fetch_into($odbc_result, $rs)) { @@ -318,4 +313,4 @@ class CI_DB_odbc_result extends CI_DB_result { } /* End of file odbc_result.php */ -/* Location: ./system/database/drivers/odbc/odbc_result.php */ +/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index c146c1785..d663da1ad 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -39,10 +39,9 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * List databases * - * @access private * @return bool */ - function _list_databases() + protected function _list_databases() { // Not sure if ODBC lets you list all databases... if ($this->db->db_debug) @@ -59,11 +58,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * - * @access private * @param string the table name * @return object */ - function _optimize_table($table) + protected function _optimize_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -80,11 +78,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * - * @access private * @param string the table name * @return object */ - function _repair_table($table) + protected function _repair_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -99,11 +96,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * ODBC Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 8c332e7f907e6af498f18fa1bf28e0a0c6e11448 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 18:09:13 -0400 Subject: PDO driver access modifiers --- system/database/drivers/pdo/pdo_driver.php | 124 +++++++++++----------------- system/database/drivers/pdo/pdo_result.php | 25 ++---- system/database/drivers/pdo/pdo_utility.php | 12 +-- 3 files changed, 63 insertions(+), 98 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 658a3d5a0..727f097f8 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -42,28 +42,31 @@ */ class CI_DB_pdo_driver extends CI_DB { - var $dbdriver = 'pdo'; + public $dbdriver = 'pdo'; // the character used to excape - not necessary for PDO - var $_escape_char = ''; + protected $_escape_char = ''; // clause and character used for LIKE escape sequences - var $_like_escape_str; - var $_like_escape_chr; + protected $_like_escape_str; + 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. + * used for the count_all() and count_all_results() public functions. */ - var $_count_string = "SELECT COUNT(*) AS "; - var $_random_keyword; + protected $_count_string = "SELECT COUNT(*) AS "; + protected $_random_keyword; // need to track the pdo driver and options - var $pdodriver; - var $options = array(); + protected $pdodriver; + protected $options = array(); - function __construct($params) + /** + * Pre-connection setup + */ + public function __construct($params) { parent::__construct($params); @@ -104,11 +107,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Connection String * - * @access private * @param array * @return void */ - function _connect_string($params) + protected function _connect_string($params) { if (strpos($this->hostname, ':')) { @@ -190,10 +192,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect() + protected function db_connect() { $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; @@ -205,10 +206,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + protected function db_pconnect() { $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; $this->options[PDO::ATTR_PERSISTENT] = TRUE; @@ -221,10 +221,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * PDO connection * - * @access private called by the PDO driver class * @return resource */ - function pdo_connect() + protected function pdo_connect() { // Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php if ($this->pdodriver == 'mysql' && is_php('5.3.6')) @@ -258,10 +257,9 @@ class CI_DB_pdo_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { if ($this->db->db_debug) { @@ -276,10 +274,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + protected function db_select() { // Not needed for PDO return TRUE; @@ -304,11 +301,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return object */ - function _execute($sql) + protected function _execute($sql) { $sql = $this->_prep_query($sql); @@ -333,11 +329,10 @@ class CI_DB_pdo_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ - function _prep_query($sql) + protected function _prep_query($sql) { if ($this->pdodriver === 'pgsql') { @@ -347,7 +342,7 @@ class CI_DB_pdo_driver extends CI_DB { elseif ($this->pdodriver === 'sqlite') { // Change the backtick(s) for SQLite - $sql = str_replace('`', '', $sql); + $sql = str_replace('`', '"', $sql); } return $sql; @@ -358,10 +353,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -387,10 +381,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -413,10 +406,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -439,12 +431,11 @@ class CI_DB_pdo_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -483,10 +474,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return $this->affect_rows; } @@ -518,11 +508,10 @@ class CI_DB_pdo_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -550,20 +539,19 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { if ($this->pdodriver == 'pgsql') { - // Analog function to show all tables in postgre + // Analog public function to show all tables in postgre $sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"; } elseif ($this->pdodriver == 'sqlite') { - // Analog function to show all tables in sqlite + // Analog public function to show all tables in sqlite $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"; } else @@ -586,11 +574,10 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + public function _list_columns($table = '') { return 'SHOW COLUMNS FROM '.$this->_from_tables($table); } @@ -602,25 +589,24 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql') { - // Analog function for mysql and postgre + // Analog public function for mysql and postgre return 'SELECT * FROM '.$this->_from_tables($table).' LIMIT 1'; } elseif ($this->pdodriver == 'oci') { - // Analog function for oci + // Analog public function for oci return 'SELECT * FROM '.$this->_from_tables($table).' WHERE ROWNUM <= 1'; } elseif ($this->pdodriver == 'sqlite') { - // Analog function for sqlite + // Analog public function for sqlite return 'PRAGMA table_info('.$this->_from_tables($table).')'; } @@ -661,13 +647,12 @@ class CI_DB_pdo_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This function escapes column and table names + * This public function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + protected function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -704,14 +689,13 @@ class CI_DB_pdo_driver extends CI_DB { /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -728,13 +712,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } @@ -746,13 +729,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert_batch($table, $keys, $values) + public function _insert_batch($table, $keys, $values) { return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES '.implode(', ', $values); } @@ -764,7 +746,6 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -772,7 +753,7 @@ class CI_DB_pdo_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -796,13 +777,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific batch update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause * @return string */ - function _update_batch($table, $values, $index, $where = NULL) + public function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); $where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; @@ -849,13 +829,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return $this->_delete($table); } @@ -867,13 +846,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -902,13 +880,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite') { @@ -930,11 +907,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { $this->conn_id = null; } @@ -942,4 +918,4 @@ class CI_DB_pdo_driver extends CI_DB { } /* End of file pdo_driver.php */ -/* Location: ./system/database/drivers/pdo/pdo_driver.php */ +/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 384b753da..330a2e677 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -51,10 +51,9 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Number of rows in the result set * - * @access public * @return integer */ - function num_rows() + public function num_rows() { if (empty($this->result_id) OR ! is_object($this->result_id)) { @@ -74,10 +73,9 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Fetch the result handler * - * @access public * @return mixed */ - function result_assoc() + public function result_assoc() { // If the result already fetched before, use that one if (count($this->result_array) > 0 OR $this->is_fetched) @@ -116,10 +114,9 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ - function num_fields() + public function num_fields() { return $this->result_id->columnCount(); } @@ -131,10 +128,9 @@ class CI_DB_pdo_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { if ($this->db->db_debug) { @@ -151,10 +147,9 @@ class CI_DB_pdo_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $data = array(); @@ -224,7 +219,7 @@ class CI_DB_pdo_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { if (is_object($this->result_id)) { @@ -241,10 +236,9 @@ class CI_DB_pdo_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return FALSE; } @@ -256,10 +250,9 @@ class CI_DB_pdo_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return $this->result_id->fetch(PDO::FETCH_ASSOC); } @@ -274,7 +267,7 @@ class CI_DB_pdo_result extends CI_DB_result { * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return $this->result_id->fetchObject(); } diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php index c278c5172..2c12d7438 100644 --- a/system/database/drivers/pdo/pdo_utility.php +++ b/system/database/drivers/pdo/pdo_utility.php @@ -39,10 +39,9 @@ class CI_DB_pdo_utility extends CI_DB_utility { /** * List databases * - * @access private * @return bool */ - function _list_databases() + protected function _list_databases() { // Not sure if PDO lets you list all databases... if ($this->db->db_debug) @@ -59,11 +58,10 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * - * @access private * @param string the table name * @return object */ - function _optimize_table($table) + protected function _optimize_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -80,11 +78,10 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * - * @access private * @param string the table name * @return object */ - function _repair_table($table) + protected function _repair_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -99,11 +96,10 @@ class CI_DB_pdo_utility extends CI_DB_utility { /** * PDO Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 7a3f89716a5ea3fc00e69342f8c9c7de77ca99ce Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 18:18:27 -0400 Subject: Postgre visibility declarations --- system/database/drivers/postgre/postgre_driver.php | 83 ++++++++-------------- system/database/drivers/postgre/postgre_forge.php | 24 +++---- system/database/drivers/postgre/postgre_result.php | 25 +++---- .../database/drivers/postgre/postgre_utility.php | 4 +- 4 files changed, 50 insertions(+), 86 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index fad9539ff..6ef83726a 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -42,29 +42,28 @@ */ class CI_DB_postgre_driver extends CI_DB { - var $dbdriver = 'postgre'; + public $dbdriver = 'postgre'; - var $_escape_char = '"'; + protected $_escape_char = '"'; // clause and character used for LIKE escape sequences - var $_like_escape_str = " ESCAPE '%s' "; - var $_like_escape_chr = '!'; + protected $_like_escape_str = " ESCAPE '%s' "; + 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. */ - var $_count_string = "SELECT COUNT(*) AS "; - var $_random_keyword = ' RANDOM()'; // database specific random keyword + protected $_count_string = "SELECT COUNT(*) AS "; + protected $_random_keyword = ' RANDOM()'; // database specific random keyword /** * Connection String * - * @access private * @return string */ - function _connect_string() + protected function _connect_string() { $components = array( 'hostname' => 'host', @@ -90,10 +89,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect() + protected function db_connect() { return @pg_connect($this->_connect_string()); } @@ -103,10 +101,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + protected function db_pconnect() { return @pg_pconnect($this->_connect_string()); } @@ -119,10 +116,9 @@ class CI_DB_postgre_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { if (pg_ping($this->conn_id) === FALSE) { @@ -135,10 +131,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + protected function db_select() { // Not needed for Postgre so we'll return TRUE return TRUE; @@ -191,11 +186,10 @@ class CI_DB_postgre_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return @pg_query($this->conn_id, $sql); } @@ -264,12 +258,11 @@ class CI_DB_postgre_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -299,10 +292,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return @pg_affected_rows($this->result_id); } @@ -312,10 +304,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Insert ID * - * @access public * @return integer */ - function insert_id() + public function insert_id() { $v = $this->version(); @@ -355,11 +346,10 @@ class CI_DB_postgre_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -384,11 +374,10 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; @@ -407,11 +396,10 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + public function _list_columns($table = '') { return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'"; } @@ -423,11 +411,10 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -454,11 +441,10 @@ class CI_DB_postgre_driver extends CI_DB { * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + protected function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -497,11 +483,10 @@ class CI_DB_postgre_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -518,13 +503,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -536,13 +520,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert_batch($table, $keys, $values) + public function _insert_batch($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); } @@ -554,7 +537,6 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -562,7 +544,7 @@ class CI_DB_postgre_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -585,11 +567,10 @@ class CI_DB_postgre_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return "TRUNCATE ".$table; } @@ -601,13 +582,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -632,13 +612,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { $sql .= "LIMIT ".$limit; @@ -655,18 +634,14 @@ class CI_DB_postgre_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @pg_close($conn_id); } - - } - /* End of file postgre_driver.php */ -/* Location: ./system/database/drivers/postgre/postgre_driver.php */ +/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 577100544..2aa6ee82a 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -39,11 +39,10 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Create database * - * @access private * @param string the database name * @return bool */ - function _create_database($name) + protected function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -53,11 +52,10 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + protected function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -70,7 +68,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - function _process_fields($fields, $primary_keys=array()) + protected function _process_fields($fields, $primary_keys=array()) { $sql = ''; $current_field_count = 0; @@ -177,7 +175,6 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -185,7 +182,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -241,8 +238,11 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Drop Table + * + * @param string the table name + * @return string */ - function _drop_table($table) + protected function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE"; } @@ -255,7 +255,6 @@ class CI_DB_postgre_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -265,7 +264,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $fields, $after_field = '') + protected function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -292,16 +291,15 @@ class CI_DB_postgre_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } /* End of file postgre_forge.php */ -/* Location: ./system/database/drivers/postgre/postgre_forge.php */ +/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index 12d7547c5..b27afaedb 100644 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.php @@ -41,10 +41,9 @@ class CI_DB_postgre_result extends CI_DB_result { /** * Number of rows in the result set * - * @access public * @return integer */ - function num_rows() + public function num_rows() { return @pg_num_rows($this->result_id); } @@ -54,10 +53,9 @@ class CI_DB_postgre_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ - function num_fields() + public function num_fields() { return @pg_num_fields($this->result_id); } @@ -69,10 +67,9 @@ class CI_DB_postgre_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -90,10 +87,9 @@ class CI_DB_postgre_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -118,7 +114,7 @@ class CI_DB_postgre_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { if (is_resource($this->result_id)) { @@ -136,10 +132,9 @@ class CI_DB_postgre_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return pg_result_seek($this->result_id, $n); } @@ -151,10 +146,9 @@ class CI_DB_postgre_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return pg_fetch_assoc($this->result_id); } @@ -166,16 +160,13 @@ class CI_DB_postgre_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return pg_fetch_object($this->result_id); } - } - /* End of file postgre_result.php */ /* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index e31a6db8f..cf29201ff 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -78,7 +78,7 @@ class CI_DB_postgre_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); @@ -86,4 +86,4 @@ class CI_DB_postgre_utility extends CI_DB_utility { } /* End of file postgre_utility.php */ -/* Location: ./system/database/drivers/postgre/postgre_utility.php */ +/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 1ed5995be34f499aec8cd7b6d4d525a33017fd94 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 18:25:43 -0400 Subject: SQlite visibility declarations --- system/database/drivers/sqlite/sqlite_driver.php | 94 ++++++++--------------- system/database/drivers/sqlite/sqlite_forge.php | 19 ++--- system/database/drivers/sqlite/sqlite_result.php | 25 ++---- system/database/drivers/sqlite/sqlite_utility.php | 2 +- 4 files changed, 50 insertions(+), 90 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 1870e73b7..6535d2753 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -42,30 +42,29 @@ */ class CI_DB_sqlite_driver extends CI_DB { - var $dbdriver = 'sqlite'; + public $dbdriver = 'sqlite'; // The character used to escape with - not needed for SQLite - var $_escape_char = ''; + protected $_escape_char = ''; // clause and character used for LIKE escape sequences - var $_like_escape_str = " ESCAPE '%s' "; - var $_like_escape_chr = '!'; + protected $_like_escape_str = " ESCAPE '%s' "; + 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. + * used for the count_all() and count_all_results() public functions. */ - var $_count_string = "SELECT COUNT(*) AS "; - var $_random_keyword = ' Random()'; // database specific random keyword + protected $_count_string = "SELECT COUNT(*) AS "; + protected $_random_keyword = ' Random()'; // database specific random keyword /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect() + protected function db_connect() { if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error)) { @@ -87,10 +86,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + protected function db_pconnect() { if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error)) { @@ -115,10 +113,9 @@ class CI_DB_sqlite_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in SQLite } @@ -128,10 +125,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + protected function db_select() { return TRUE; } @@ -155,11 +151,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return @sqlite_query($this->conn_id, $sql); } @@ -169,10 +164,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -199,10 +193,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -224,10 +217,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -249,12 +241,11 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -284,10 +275,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return sqlite_changes($this->conn_id); } @@ -297,10 +287,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Insert ID * - * @access public * @return integer */ - function insert_id() + public function insert_id() { return @sqlite_last_insert_rowid($this->conn_id); } @@ -313,11 +302,10 @@ class CI_DB_sqlite_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -342,11 +330,10 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT name from sqlite_master WHERE type='table'"; @@ -364,11 +351,10 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + public function _list_columns($table = '') { // Not supported return FALSE; @@ -381,11 +367,10 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -412,13 +397,12 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This function escapes column and table names + * This public function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + protected function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -454,14 +438,13 @@ class CI_DB_sqlite_driver extends CI_DB { /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -478,13 +461,12 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -496,7 +478,6 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -504,7 +485,7 @@ class CI_DB_sqlite_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -532,13 +513,12 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return $this->_delete($table); } @@ -550,13 +530,12 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -584,13 +563,12 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -609,18 +587,14 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @sqlite_close($conn_id); } - - } - /* End of file sqlite_driver.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 7fc531463..595d41968 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -43,7 +43,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the database name * @return bool */ - function _create_database() + public function _create_database() { // In SQLite, a database is created when you connect to the database. // We'll return TRUE so that an error isn't generated @@ -55,11 +55,10 @@ class CI_DB_sqlite_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + protected function _drop_database($name) { if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) { @@ -76,7 +75,6 @@ class CI_DB_sqlite_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -84,7 +82,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -186,10 +184,9 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * * Unsupported feature in SQLite * - * @access private * @return bool */ - function _drop_table($table) + protected function _drop_table($table) { if ($this->db->db_debug) { @@ -206,7 +203,6 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -216,7 +212,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -261,12 +257,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -274,4 +269,4 @@ class CI_DB_sqlite_forge extends CI_DB_forge { } /* End of file sqlite_forge.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php index ac2235cbc..beb4db6cd 100644 --- a/system/database/drivers/sqlite/sqlite_result.php +++ b/system/database/drivers/sqlite/sqlite_result.php @@ -41,10 +41,9 @@ class CI_DB_sqlite_result extends CI_DB_result { /** * Number of rows in the result set * - * @access public * @return integer */ - function num_rows() + public function num_rows() { return @sqlite_num_rows($this->result_id); } @@ -54,10 +53,9 @@ class CI_DB_sqlite_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ - function num_fields() + public function num_fields() { return @sqlite_num_fields($this->result_id); } @@ -69,10 +67,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -90,10 +87,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -118,7 +114,7 @@ class CI_DB_sqlite_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { // Not implemented in SQLite } @@ -132,10 +128,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return sqlite_seek($this->result_id, $n); } @@ -147,10 +142,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return sqlite_fetch_array($this->result_id); } @@ -162,10 +156,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { if (function_exists('sqlite_fetch_object')) { @@ -183,9 +176,7 @@ class CI_DB_sqlite_result extends CI_DB_result { } } } - } - /* End of file sqlite_result.php */ /* Location: ./system/database/drivers/sqlite/sqlite_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index 9f9ddca44..c07004c54 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -94,4 +94,4 @@ class CI_DB_sqlite_utility extends CI_DB_utility { } /* End of file sqlite_utility.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b4172695910bf8c0c07933e9baf536d22c9e097a Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 18:34:11 -0400 Subject: Sqlsrv driver visibility declarations --- system/database/drivers/sqlsrv/sqlsrv_driver.php | 109 +++++++++------------- system/database/drivers/sqlsrv/sqlsrv_forge.php | 20 ++-- system/database/drivers/sqlsrv/sqlsrv_result.php | 24 ++--- system/database/drivers/sqlsrv/sqlsrv_utility.php | 12 +-- 4 files changed, 61 insertions(+), 104 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index ea9f9483b..95ab61b9f 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -42,30 +42,29 @@ */ class CI_DB_sqlsrv_driver extends CI_DB { - var $dbdriver = 'sqlsrv'; + public $dbdriver = 'sqlsrv'; // The character used for escaping - var $_escape_char = ''; + protected $_escape_char = ''; // clause and character used for LIKE escape sequences - var $_like_escape_str = " ESCAPE '%s' "; - var $_like_escape_chr = '!'; + protected $_like_escape_str = " ESCAPE '%s' "; + 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. + * used for the count_all() and count_all_results() public functions. */ - var $_count_string = "SELECT COUNT(*) AS "; - var $_random_keyword = ' ASC'; // not currently supported + protected $_count_string = "SELECT COUNT(*) AS "; + protected $_random_keyword = ' ASC'; // not currently supported /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect($pooling = false) + protected function db_connect($pooling = false) { // Check for a UTF-8 charset being passed as CI's default 'utf8'. $character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set; @@ -93,10 +92,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + protected function db_pconnect() { return $this->db_connect(TRUE); } @@ -109,10 +107,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in MSSQL } @@ -146,11 +143,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return sqlsrv_query($this->conn_id, $sql, null, array( 'Scrollable' => SQLSRV_CURSOR_STATIC, @@ -163,10 +159,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -192,10 +187,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -216,10 +210,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -240,12 +233,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { // Escape single quotes return str_replace("'", "''", $str); @@ -256,10 +248,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return @sqlrv_rows_affected($this->conn_id); } @@ -271,10 +262,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Returns the last id created in the Identity column. * - * @access public * @return integer */ - function insert_id() + public function insert_id() { return $this->query('select @@IDENTITY as insert_id')->row('insert_id'); } @@ -287,11 +277,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Grabs the major version number from the * database server version string passed in. * - * @access private * @param string $version * @return int16 major version number */ - function _parse_major_version($version) + protected function _parse_major_version($version) { preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); return $ver_info[1]; // return the major version b/c that's all we're interested in. @@ -327,11 +316,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') return '0'; @@ -353,11 +341,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; } @@ -369,11 +356,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access private * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'"; } @@ -385,11 +371,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { return "SELECT TOP 1 * FROM " . $this->_escape_table($table); } @@ -437,46 +422,44 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Escape Table Name * - * This function adds backticks if the table name has a period + * This public function adds backticks if the table name has a period * in it. Some DBs will get cranky unless periods are escaped * - * @access private * @param string the table name * @return string */ - function _escape_table($table) + protected function _escape_table($table) { return $table; - } - + } + + // -------------------------------------------------------------------------- /** * Escape the SQL Identifiers * - * This function escapes column and table names + * This public function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + protected function _escape_identifiers($item) { return $item; } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------------- /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param string the table name + * @return string */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -493,13 +476,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -511,7 +493,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -519,7 +500,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where) + public function _update($table, $values, $where) { foreach($values as $key => $val) { @@ -536,13 +517,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return "TRUNCATE ".$table; } @@ -554,13 +534,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where) + public function _delete($table, $where) { return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where); } @@ -572,13 +551,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { $i = $limit + $offset; @@ -590,18 +568,15 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @sqlsrv_close($conn_id); } } - - /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index cd061dd23..645274232 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -39,11 +39,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Create database * - * @access private * @param string the database name * @return bool */ - function _create_database($name) + protected function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -53,11 +52,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + protected function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -67,10 +65,9 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return bool */ - function _drop_table($table) + protected function _drop_table($table) { return "DROP TABLE ".$this->db->_escape_identifiers($table); } @@ -80,7 +77,6 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -88,7 +84,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -190,7 +186,6 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -200,7 +195,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -242,12 +237,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); @@ -256,4 +250,4 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { } /* End of file sqlsrv_forge.php */ -/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php index 52d338a30..095e3440a 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_result.php +++ b/system/database/drivers/sqlsrv/sqlsrv_result.php @@ -41,10 +41,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { /** * Number of rows in the result set * - * @access public * @return integer */ - function num_rows() + public function num_rows() { return @sqlsrv_num_rows($this->result_id); } @@ -54,10 +53,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ - function num_fields() + pubilc function num_fields() { return @sqlsrv_num_fields($this->result_id); } @@ -69,10 +67,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field) @@ -90,10 +87,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field) @@ -118,7 +114,7 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { if (is_resource($this->result_id)) { @@ -136,10 +132,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { // Not implemented } @@ -151,10 +146,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC); } @@ -166,16 +160,14 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return sqlsrv_fetch_object($this->result_id); } } - /* End of file mssql_result.php */ /* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index 44e6fafeb..9e9dde32e 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php @@ -39,10 +39,9 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { /** * List databases * - * @access private * @return bool */ - function _list_databases() + protected function _list_databases() { return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases } @@ -54,11 +53,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * - * @access private * @param string the table name * @return object */ - function _optimize_table($table) + protected function _optimize_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -70,11 +68,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * - * @access private * @param string the table name * @return object */ - function _repair_table($table) + protected function _repair_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -84,11 +81,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { /** * MSSQL Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 9cc5c60052d1942a5f49016a8f36cf90b27b7c78 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 18:36:37 -0400 Subject: Minor mysql/mysqli formatting fixes --- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/mysql/mysql_forge.php | 2 +- system/database/drivers/mysql/mysql_result.php | 2 +- system/database/drivers/mysql/mysql_utility.php | 2 +- system/database/drivers/mysqli/mysqli_driver.php | 2 +- system/database/drivers/mysqli/mysqli_forge.php | 2 +- system/database/drivers/mysqli/mysqli_result.php | 2 +- system/database/drivers/mysqli/mysqli_utility.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index ba646d226..bef4111c3 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -701,4 +701,4 @@ class CI_DB_mysql_driver extends CI_DB { } /* End of file mysql_driver.php */ -/* Location: ./system/database/drivers/mysql/mysql_driver.php */ +/* Location: ./system/database/drivers/mysql/mysql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 004a5a103..8e5143818 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -237,4 +237,4 @@ class CI_DB_mysql_forge extends CI_DB_forge { } /* End of file mysql_forge.php */ -/* Location: ./system/database/drivers/mysql/mysql_forge.php */ +/* Location: ./system/database/drivers/mysql/mysql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index cec28dc2d..f76076f4c 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -166,4 +166,4 @@ class CI_DB_mysql_result extends CI_DB_result { } /* End of file mysql_result.php */ -/* Location: ./system/database/drivers/mysql/mysql_result.php */ +/* Location: ./system/database/drivers/mysql/mysql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index d716b004a..2d89cb9cb 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -204,4 +204,4 @@ class CI_DB_mysql_utility extends CI_DB_utility { } /* End of file mysql_utility.php */ -/* Location: ./system/database/drivers/mysql/mysql_utility.php */ +/* Location: ./system/database/drivers/mysql/mysql_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index f38b94c13..4c5d52127 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -697,4 +697,4 @@ class CI_DB_mysqli_driver extends CI_DB { } /* End of file mysqli_driver.php */ -/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 9cb1a0c70..c1be117f3 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -237,4 +237,4 @@ class CI_DB_mysqli_forge extends CI_DB_forge { } /* End of file mysqli_forge.php */ -/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index f135f4d46..83d88aae3 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -167,4 +167,4 @@ class CI_DB_mysqli_result extends CI_DB_result { } /* End of file mysqli_result.php */ -/* Location: ./system/database/drivers/mysqli/mysqli_result.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 650ddfd18..4d7002e78 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -90,4 +90,4 @@ class CI_DB_mysqli_utility extends CI_DB_utility { } /* End of file mysqli_utility.php */ -/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 78a2de4e049f478ec1efd92d639aaf11be933335 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 18:57:56 -0400 Subject: Fixed visibility declarations on dbforge and utility classes --- system/database/drivers/cubrid/cubrid_forge.php | 14 +++++++------- system/database/drivers/cubrid/cubrid_utility.php | 8 ++++---- system/database/drivers/oci8/oci8_forge.php | 8 ++++---- system/database/drivers/oci8/oci8_utility.php | 8 ++++---- system/database/drivers/odbc/odbc_forge.php | 12 ++++++------ system/database/drivers/odbc/odbc_utility.php | 8 ++++---- system/database/drivers/pdo/pdo_forge.php | 20 +++++++------------- system/database/drivers/pdo/pdo_utility.php | 8 ++++---- system/database/drivers/postgre/postgre_forge.php | 14 +++++++------- system/database/drivers/sqlite/sqlite_forge.php | 10 +++++----- system/database/drivers/sqlsrv/sqlsrv_forge.php | 12 ++++++------ system/database/drivers/sqlsrv/sqlsrv_utility.php | 8 ++++---- 12 files changed, 62 insertions(+), 68 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 6bfc7c28f..c3251bd3f 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -42,7 +42,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _create_database($name) + public function _create_database($name) { // CUBRID does not allow to create a database in SQL. The GUI tools // have to be used for this purpose. @@ -57,7 +57,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _drop_database($name) + public function _drop_database($name) { // CUBRID does not allow to drop a database in SQL. The GUI tools // have to be used for this purpose. @@ -72,7 +72,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - protected function _process_fields($fields) + public function _process_fields($fields) { $current_field_count = 0; $sql = ''; @@ -176,7 +176,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -230,7 +230,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * * @return string */ - protected function _drop_table($table) + public function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table); } @@ -249,7 +249,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $fields, $after_field = '') + public function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -280,7 +280,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php index de28e6335..bc54e7a1b 100644 --- a/system/database/drivers/cubrid/cubrid_utility.php +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -42,7 +42,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @access private * @return array */ - protected function _list_databases() + public function _list_databases() { // CUBRID does not allow to see the list of all databases on the // server. It is the way its architecture is designed. Every @@ -71,7 +71,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Optimize%20Database */ - protected function _optimize_table($table) + public function _optimize_table($table) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table optimization can be performed using CUBRID Manager @@ -91,7 +91,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency */ - protected function _repair_table($table) + public function _repair_table($table) { // Not supported in CUBRID as of version 8.4.0. Database or // table consistency can be checked using CUBRID Manager @@ -107,7 +107,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + public function _backup($params = array()) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table backup can be performed using CUBRID Manager diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index f9a90ff0a..c59cfa709 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -55,7 +55,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _drop_database($name) + public function _drop_database($name) { return FALSE; } @@ -144,7 +144,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * * @return bool */ - protected function _drop_table($table) + public function _drop_table($table) { return FALSE; } @@ -166,7 +166,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -212,7 +212,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index f4863c0db..bfbf87140 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -41,7 +41,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * * @return bool */ - protected function _list_databases() + public function _list_databases() { return FALSE; } @@ -56,7 +56,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _optimize_table($table) + public function _optimize_table($table) { return FALSE; // Is this supported in Oracle? } @@ -71,7 +71,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _repair_table($table) + public function _repair_table($table) { return FALSE; // Is this supported in Oracle? } @@ -84,7 +84,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index 121c09606..c5b062e5c 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -42,7 +42,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _create_database() + public function _create_database() { // ODBC has no "create database" command since it's // designed to connect to an existing database @@ -61,7 +61,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _drop_database($name) + public function _drop_database($name) { // ODBC has no "drop database" command since it's // designed to connect to an existing database @@ -84,7 +84,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -185,7 +185,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * * @return bool */ - protected function _drop_table($table) + public function _drop_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -212,7 +212,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -259,7 +259,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index d663da1ad..a07d3b64e 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -41,7 +41,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * @return bool */ - protected function _list_databases() + public function _list_databases() { // Not sure if ODBC lets you list all databases... if ($this->db->db_debug) @@ -61,7 +61,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _optimize_table($table) + public function _optimize_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -81,7 +81,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _repair_table($table) + public function _repair_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -99,7 +99,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 87b638570..7fca962b3 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -39,11 +39,10 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Create database * - * @access private * @param string the database name * @return bool */ - function _create_database() + public function _create_database() { // PDO has no "create database" command since it's // designed to connect to an existing database @@ -59,11 +58,10 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Drop database * - * @access private * @param string the database name * @return bool */ - function _drop_database($name) + public function _drop_database($name) { // PDO has no "drop database" command since it's // designed to connect to an existing database @@ -79,7 +77,6 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -87,7 +84,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -191,10 +188,9 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return bool */ - function _drop_table($table) + public function _drop_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -212,7 +208,6 @@ class CI_DB_pdo_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -222,7 +217,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -265,12 +260,11 @@ class CI_DB_pdo_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -278,4 +272,4 @@ class CI_DB_pdo_forge extends CI_DB_forge { } /* End of file pdo_forge.php */ -/* Location: ./system/database/drivers/pdo/pdo_forge.php */ +/* Location: ./system/database/drivers/pdo/pdo_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php index 2c12d7438..02373b720 100644 --- a/system/database/drivers/pdo/pdo_utility.php +++ b/system/database/drivers/pdo/pdo_utility.php @@ -41,7 +41,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * @return bool */ - protected function _list_databases() + public function _list_databases() { // Not sure if PDO lets you list all databases... if ($this->db->db_debug) @@ -61,7 +61,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _optimize_table($table) + public function _optimize_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -81,7 +81,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _repair_table($table) + public function _repair_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -99,7 +99,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 2aa6ee82a..04622586d 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -42,7 +42,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _create_database($name) + public function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -55,7 +55,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _drop_database($name) + public function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -68,7 +68,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - protected function _process_fields($fields, $primary_keys=array()) + public function _process_fields($fields, $primary_keys=array()) { $sql = ''; $current_field_count = 0; @@ -182,7 +182,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -242,7 +242,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the table name * @return string */ - protected function _drop_table($table) + public function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE"; } @@ -264,7 +264,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $fields, $after_field = '') + public function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -295,7 +295,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 595d41968..4b22989ea 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -58,7 +58,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _drop_database($name) + public function _drop_database($name) { if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) { @@ -82,7 +82,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -186,7 +186,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * * @return bool */ - protected function _drop_table($table) + public function _drop_table($table) { if ($this->db->db_debug) { @@ -212,7 +212,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -261,7 +261,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 645274232..b7b45a4e6 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -42,7 +42,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _create_database($name) + public function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -55,7 +55,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the database name * @return bool */ - protected function _drop_database($name) + public function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -67,7 +67,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * * @return bool */ - protected function _drop_table($table) + public function _drop_table($table) { return "DROP TABLE ".$this->db->_escape_identifiers($table); } @@ -84,7 +84,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -195,7 +195,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -241,7 +241,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index 9e9dde32e..4d40f0675 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php @@ -41,7 +41,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * * @return bool */ - protected function _list_databases() + public function _list_databases() { return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases } @@ -56,7 +56,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _optimize_table($table) + public function _optimize_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -71,7 +71,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * @param string the table name * @return object */ - protected function _repair_table($table) + public function _repair_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -84,7 +84,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 5137ebcafe525752bfc79abc0628e45f55eb196e Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:05:25 -0400 Subject: Revert "Fixed visibility declarations on dbforge and utility classes" This reverts commit 78a2de4e049f478ec1efd92d639aaf11be933335. --- system/database/drivers/cubrid/cubrid_forge.php | 14 +++++++------- system/database/drivers/cubrid/cubrid_utility.php | 8 ++++---- system/database/drivers/oci8/oci8_forge.php | 8 ++++---- system/database/drivers/oci8/oci8_utility.php | 8 ++++---- system/database/drivers/odbc/odbc_forge.php | 12 ++++++------ system/database/drivers/odbc/odbc_utility.php | 8 ++++---- system/database/drivers/pdo/pdo_forge.php | 20 +++++++++++++------- system/database/drivers/pdo/pdo_utility.php | 8 ++++---- system/database/drivers/postgre/postgre_forge.php | 14 +++++++------- system/database/drivers/sqlite/sqlite_forge.php | 10 +++++----- system/database/drivers/sqlsrv/sqlsrv_forge.php | 12 ++++++------ system/database/drivers/sqlsrv/sqlsrv_utility.php | 8 ++++---- 12 files changed, 68 insertions(+), 62 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index c3251bd3f..6bfc7c28f 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -42,7 +42,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _create_database($name) + protected function _create_database($name) { // CUBRID does not allow to create a database in SQL. The GUI tools // have to be used for this purpose. @@ -57,7 +57,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _drop_database($name) + protected function _drop_database($name) { // CUBRID does not allow to drop a database in SQL. The GUI tools // have to be used for this purpose. @@ -72,7 +72,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - public function _process_fields($fields) + protected function _process_fields($fields) { $current_field_count = 0; $sql = ''; @@ -176,7 +176,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -230,7 +230,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * * @return string */ - public function _drop_table($table) + protected function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table); } @@ -249,7 +249,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - public function _alter_table($alter_type, $table, $fields, $after_field = '') + protected function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -280,7 +280,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php index bc54e7a1b..de28e6335 100644 --- a/system/database/drivers/cubrid/cubrid_utility.php +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -42,7 +42,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @access private * @return array */ - public function _list_databases() + protected function _list_databases() { // CUBRID does not allow to see the list of all databases on the // server. It is the way its architecture is designed. Every @@ -71,7 +71,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Optimize%20Database */ - public function _optimize_table($table) + protected function _optimize_table($table) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table optimization can be performed using CUBRID Manager @@ -91,7 +91,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency */ - public function _repair_table($table) + protected function _repair_table($table) { // Not supported in CUBRID as of version 8.4.0. Database or // table consistency can be checked using CUBRID Manager @@ -107,7 +107,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - public function _backup($params = array()) + protected function _backup($params = array()) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table backup can be performed using CUBRID Manager diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index c59cfa709..f9a90ff0a 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -55,7 +55,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _drop_database($name) + protected function _drop_database($name) { return FALSE; } @@ -144,7 +144,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * * @return bool */ - public function _drop_table($table) + protected function _drop_table($table) { return FALSE; } @@ -166,7 +166,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -212,7 +212,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index bfbf87140..f4863c0db 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -41,7 +41,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * * @return bool */ - public function _list_databases() + protected function _list_databases() { return FALSE; } @@ -56,7 +56,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _optimize_table($table) + protected function _optimize_table($table) { return FALSE; // Is this supported in Oracle? } @@ -71,7 +71,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _repair_table($table) + protected function _repair_table($table) { return FALSE; // Is this supported in Oracle? } @@ -84,7 +84,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - public function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index c5b062e5c..121c09606 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -42,7 +42,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _create_database() + protected function _create_database() { // ODBC has no "create database" command since it's // designed to connect to an existing database @@ -61,7 +61,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _drop_database($name) + protected function _drop_database($name) { // ODBC has no "drop database" command since it's // designed to connect to an existing database @@ -84,7 +84,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -185,7 +185,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * * @return bool */ - public function _drop_table($table) + protected function _drop_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -212,7 +212,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -259,7 +259,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index a07d3b64e..d663da1ad 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -41,7 +41,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * @return bool */ - public function _list_databases() + protected function _list_databases() { // Not sure if ODBC lets you list all databases... if ($this->db->db_debug) @@ -61,7 +61,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _optimize_table($table) + protected function _optimize_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -81,7 +81,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _repair_table($table) + protected function _repair_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -99,7 +99,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - public function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 7fca962b3..87b638570 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -39,10 +39,11 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Create database * + * @access private * @param string the database name * @return bool */ - public function _create_database() + function _create_database() { // PDO has no "create database" command since it's // designed to connect to an existing database @@ -58,10 +59,11 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - public function _drop_database($name) + function _drop_database($name) { // PDO has no "drop database" command since it's // designed to connect to an existing database @@ -77,6 +79,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Create Table * + * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -84,7 +87,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -188,9 +191,10 @@ class CI_DB_pdo_forge extends CI_DB_forge { /** * Drop Table * + * @access private * @return bool */ - public function _drop_table($table) + function _drop_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -208,6 +212,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -217,7 +222,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -260,11 +265,12 @@ class CI_DB_pdo_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -272,4 +278,4 @@ class CI_DB_pdo_forge extends CI_DB_forge { } /* End of file pdo_forge.php */ -/* Location: ./system/database/drivers/pdo/pdo_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/pdo/pdo_forge.php */ diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php index 02373b720..2c12d7438 100644 --- a/system/database/drivers/pdo/pdo_utility.php +++ b/system/database/drivers/pdo/pdo_utility.php @@ -41,7 +41,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * @return bool */ - public function _list_databases() + protected function _list_databases() { // Not sure if PDO lets you list all databases... if ($this->db->db_debug) @@ -61,7 +61,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _optimize_table($table) + protected function _optimize_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -81,7 +81,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _repair_table($table) + protected function _repair_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -99,7 +99,7 @@ class CI_DB_pdo_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - public function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 04622586d..2aa6ee82a 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -42,7 +42,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _create_database($name) + protected function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -55,7 +55,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _drop_database($name) + protected function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -68,7 +68,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - public function _process_fields($fields, $primary_keys=array()) + protected function _process_fields($fields, $primary_keys=array()) { $sql = ''; $current_field_count = 0; @@ -182,7 +182,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -242,7 +242,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the table name * @return string */ - public function _drop_table($table) + protected function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE"; } @@ -264,7 +264,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - public function _alter_table($alter_type, $table, $fields, $after_field = '') + protected function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -295,7 +295,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 4b22989ea..595d41968 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -58,7 +58,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _drop_database($name) + protected function _drop_database($name) { if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) { @@ -82,7 +82,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -186,7 +186,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * * @return bool */ - public function _drop_table($table) + protected function _drop_table($table) { if ($this->db->db_debug) { @@ -212,7 +212,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -261,7 +261,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index b7b45a4e6..645274232 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -42,7 +42,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _create_database($name) + protected function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -55,7 +55,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _drop_database($name) + protected function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -67,7 +67,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * * @return bool */ - public function _drop_table($table) + protected function _drop_table($table) { return "DROP TABLE ".$this->db->_escape_identifiers($table); } @@ -84,7 +84,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -195,7 +195,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -241,7 +241,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index 4d40f0675..9e9dde32e 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php @@ -41,7 +41,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * * @return bool */ - public function _list_databases() + protected function _list_databases() { return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases } @@ -56,7 +56,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _optimize_table($table) + protected function _optimize_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -71,7 +71,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * @param string the table name * @return object */ - public function _repair_table($table) + protected function _repair_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -84,7 +84,7 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - public function _backup($params = array()) + protected function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 0e20da17ff71bbe4a7082940b38f6161d7b6e7f8 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:05:46 -0400 Subject: Revert "Sqlsrv driver visibility declarations" This reverts commit b4172695910bf8c0c07933e9baf536d22c9e097a. --- system/database/drivers/sqlsrv/sqlsrv_driver.php | 109 +++++++++++++--------- system/database/drivers/sqlsrv/sqlsrv_forge.php | 20 ++-- system/database/drivers/sqlsrv/sqlsrv_result.php | 24 +++-- system/database/drivers/sqlsrv/sqlsrv_utility.php | 12 ++- 4 files changed, 104 insertions(+), 61 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 95ab61b9f..ea9f9483b 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -42,29 +42,30 @@ */ class CI_DB_sqlsrv_driver extends CI_DB { - public $dbdriver = 'sqlsrv'; + var $dbdriver = 'sqlsrv'; // The character used for escaping - protected $_escape_char = ''; + var $_escape_char = ''; // clause and character used for LIKE escape sequences - protected $_like_escape_str = " ESCAPE '%s' "; - protected $_like_escape_chr = '!'; + var $_like_escape_str = " ESCAPE '%s' "; + var $_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() public functions. + * used for the count_all() and count_all_results() functions. */ - protected $_count_string = "SELECT COUNT(*) AS "; - protected $_random_keyword = ' ASC'; // not currently supported + var $_count_string = "SELECT COUNT(*) AS "; + var $_random_keyword = ' ASC'; // not currently supported /** * Non-persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_connect($pooling = false) + function db_connect($pooling = false) { // Check for a UTF-8 charset being passed as CI's default 'utf8'. $character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set; @@ -92,9 +93,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_pconnect() + function db_pconnect() { return $this->db_connect(TRUE); } @@ -107,9 +109,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * + * @access public * @return void */ - public function reconnect() + function reconnect() { // not implemented in MSSQL } @@ -143,10 +146,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Execute the query * + * @access private called by the base class * @param string an SQL query * @return resource */ - protected function _execute($sql) + function _execute($sql) { return sqlsrv_query($this->conn_id, $sql, null, array( 'Scrollable' => SQLSRV_CURSOR_STATIC, @@ -159,9 +163,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Begin Transaction * + * @access public * @return bool */ - public function trans_begin($test_mode = FALSE) + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -187,9 +192,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Commit Transaction * + * @access public * @return bool */ - public function trans_commit() + function trans_commit() { if ( ! $this->trans_enabled) { @@ -210,9 +216,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Rollback Transaction * + * @access public * @return bool */ - public function trans_rollback() + function trans_rollback() { if ( ! $this->trans_enabled) { @@ -233,11 +240,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Escape String * + * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - public function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { // Escape single quotes return str_replace("'", "''", $str); @@ -248,9 +256,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Affected Rows * + * @access public * @return integer */ - public function affected_rows() + function affected_rows() { return @sqlrv_rows_affected($this->conn_id); } @@ -262,9 +271,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Returns the last id created in the Identity column. * + * @access public * @return integer */ - public function insert_id() + function insert_id() { return $this->query('select @@IDENTITY as insert_id')->row('insert_id'); } @@ -277,10 +287,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Grabs the major version number from the * database server version string passed in. * + * @access private * @param string $version * @return int16 major version number */ - protected function _parse_major_version($version) + function _parse_major_version($version) { preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); return $ver_info[1]; // return the major version b/c that's all we're interested in. @@ -316,10 +327,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * + * @access public * @param string * @return string */ - public function count_all($table = '') + function count_all($table = '') { if ($table == '') return '0'; @@ -341,10 +353,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * + * @access private * @param boolean * @return string */ - protected function _list_tables($prefix_limit = FALSE) + function _list_tables($prefix_limit = FALSE) { return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; } @@ -356,10 +369,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * + * @access private * @param string the table name * @return string */ - protected function _list_columns($table = '') + function _list_columns($table = '') { return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'"; } @@ -371,10 +385,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * + * @access public * @param string the table name * @return object */ - public function _field_data($table) + function _field_data($table) { return "SELECT TOP 1 * FROM " . $this->_escape_table($table); } @@ -422,44 +437,46 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Escape Table Name * - * This public function adds backticks if the table name has a period + * This function adds backticks if the table name has a period * in it. Some DBs will get cranky unless periods are escaped * + * @access private * @param string the table name * @return string */ - protected function _escape_table($table) + function _escape_table($table) { return $table; - } - - // -------------------------------------------------------------------------- + } + /** * Escape the SQL Identifiers * - * This public function escapes column and table names + * This function escapes column and table names * + * @access private * @param string * @return string */ - protected function _escape_identifiers($item) + function _escape_identifiers($item) { return $item; } - // -------------------------------------------------------------------------- + // -------------------------------------------------------------------- /** * From Tables * - * This public function implicitly groups FROM tables so there is no confusion + * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @param string the table name - * @return string + * @access public + * @param type + * @return type */ - public function _from_tables($tables) + function _from_tables($tables) { if ( ! is_array($tables)) { @@ -476,12 +493,13 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + function _insert($table, $keys, $values) { return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -493,6 +511,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -500,7 +519,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { * @param array the limit clause * @return string */ - public function _update($table, $values, $where) + function _update($table, $values, $where) { foreach($values as $key => $val) { @@ -517,12 +536,13 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This public function maps to "DELETE FROM table" + * This function maps to "DELETE FROM table" * + * @access public * @param string the table name * @return string */ - public function _truncate($table) + function _truncate($table) { return "TRUNCATE ".$table; } @@ -534,12 +554,13 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * + * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - public function _delete($table, $where) + function _delete($table, $where) { return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where); } @@ -551,12 +572,13 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * + * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + function _limit($sql, $limit, $offset) { $i = $limit + $offset; @@ -568,15 +590,18 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Close DB Connection * + * @access public * @param resource * @return void */ - public function _close($conn_id) + function _close($conn_id) { @sqlsrv_close($conn_id); } } + + /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 645274232..cd061dd23 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -39,10 +39,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Create database * + * @access private * @param string the database name * @return bool */ - protected function _create_database($name) + function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -52,10 +53,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - protected function _drop_database($name) + function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -65,9 +67,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Drop Table * + * @access private * @return bool */ - protected function _drop_table($table) + function _drop_table($table) { return "DROP TABLE ".$this->db->_escape_identifiers($table); } @@ -77,6 +80,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Create Table * + * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -84,7 +88,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -186,6 +190,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -195,7 +200,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -237,11 +242,12 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); @@ -250,4 +256,4 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { } /* End of file sqlsrv_forge.php */ -/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php index 095e3440a..52d338a30 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_result.php +++ b/system/database/drivers/sqlsrv/sqlsrv_result.php @@ -41,9 +41,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result { /** * Number of rows in the result set * + * @access public * @return integer */ - public function num_rows() + function num_rows() { return @sqlsrv_num_rows($this->result_id); } @@ -53,9 +54,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result { /** * Number of fields in the result set * + * @access public * @return integer */ - pubilc function num_fields() + function num_fields() { return @sqlsrv_num_fields($this->result_id); } @@ -67,9 +69,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Generates an array of column names * + * @access public * @return array */ - public function list_fields() + function list_fields() { $field_names = array(); foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field) @@ -87,9 +90,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * + * @access public * @return array */ - public function field_data() + function field_data() { $retval = array(); foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field) @@ -114,7 +118,7 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * @return null */ - public function free_result() + function free_result() { if (is_resource($this->result_id)) { @@ -132,9 +136,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * + * @access private * @return array */ - protected function _data_seek($n = 0) + function _data_seek($n = 0) { // Not implemented } @@ -146,9 +151,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Returns the result set as an array * + * @access private * @return array */ - protected function _fetch_assoc() + function _fetch_assoc() { return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC); } @@ -160,14 +166,16 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Returns the result set as an object * + * @access private * @return object */ - protected function _fetch_object() + function _fetch_object() { return sqlsrv_fetch_object($this->result_id); } } + /* End of file mssql_result.php */ /* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index 9e9dde32e..44e6fafeb 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php @@ -39,9 +39,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { /** * List databases * + * @access private * @return bool */ - protected function _list_databases() + function _list_databases() { return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases } @@ -53,10 +54,11 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * + * @access private * @param string the table name * @return object */ - protected function _optimize_table($table) + function _optimize_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -68,10 +70,11 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * + * @access private * @param string the table name * @return object */ - protected function _repair_table($table) + function _repair_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -81,10 +84,11 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { /** * MSSQL Export * + * @access private * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 691a8e747dc3b9a277488b133a5a02914ff210eb Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:06:00 -0400 Subject: Revert "SQlite visibility declarations" This reverts commit 1ed5995be34f499aec8cd7b6d4d525a33017fd94. --- system/database/drivers/sqlite/sqlite_driver.php | 94 +++++++++++++++-------- system/database/drivers/sqlite/sqlite_forge.php | 19 +++-- system/database/drivers/sqlite/sqlite_result.php | 25 ++++-- system/database/drivers/sqlite/sqlite_utility.php | 2 +- 4 files changed, 90 insertions(+), 50 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 6535d2753..1870e73b7 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -42,29 +42,30 @@ */ class CI_DB_sqlite_driver extends CI_DB { - public $dbdriver = 'sqlite'; + var $dbdriver = 'sqlite'; // The character used to escape with - not needed for SQLite - protected $_escape_char = ''; + var $_escape_char = ''; // clause and character used for LIKE escape sequences - protected $_like_escape_str = " ESCAPE '%s' "; - protected $_like_escape_chr = '!'; + var $_like_escape_str = " ESCAPE '%s' "; + var $_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() public functions. + * used for the count_all() and count_all_results() functions. */ - protected $_count_string = "SELECT COUNT(*) AS "; - protected $_random_keyword = ' Random()'; // database specific random keyword + var $_count_string = "SELECT COUNT(*) AS "; + var $_random_keyword = ' Random()'; // database specific random keyword /** * Non-persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_connect() + function db_connect() { if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error)) { @@ -86,9 +87,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_pconnect() + function db_pconnect() { if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error)) { @@ -113,9 +115,10 @@ class CI_DB_sqlite_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * + * @access public * @return void */ - public function reconnect() + function reconnect() { // not implemented in SQLite } @@ -125,9 +128,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Select the database * + * @access private called by the base class * @return resource */ - protected function db_select() + function db_select() { return TRUE; } @@ -151,10 +155,11 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Execute the query * + * @access private called by the base class * @param string an SQL query * @return resource */ - protected function _execute($sql) + function _execute($sql) { return @sqlite_query($this->conn_id, $sql); } @@ -164,9 +169,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Begin Transaction * + * @access public * @return bool */ - public function trans_begin($test_mode = FALSE) + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -193,9 +199,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Commit Transaction * + * @access public * @return bool */ - public function trans_commit() + function trans_commit() { if ( ! $this->trans_enabled) { @@ -217,9 +224,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Rollback Transaction * + * @access public * @return bool */ - public function trans_rollback() + function trans_rollback() { if ( ! $this->trans_enabled) { @@ -241,11 +249,12 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Escape String * + * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - public function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -275,9 +284,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Affected Rows * + * @access public * @return integer */ - public function affected_rows() + function affected_rows() { return sqlite_changes($this->conn_id); } @@ -287,9 +297,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Insert ID * + * @access public * @return integer */ - public function insert_id() + function insert_id() { return @sqlite_last_insert_rowid($this->conn_id); } @@ -302,10 +313,11 @@ class CI_DB_sqlite_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * + * @access public * @param string * @return string */ - public function count_all($table = '') + function count_all($table = '') { if ($table == '') { @@ -330,10 +342,11 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * + * @access private * @param boolean * @return string */ - protected function _list_tables($prefix_limit = FALSE) + function _list_tables($prefix_limit = FALSE) { $sql = "SELECT name from sqlite_master WHERE type='table'"; @@ -351,10 +364,11 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * + * @access public * @param string the table name * @return string */ - public function _list_columns($table = '') + function _list_columns($table = '') { // Not supported return FALSE; @@ -367,10 +381,11 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * + * @access public * @param string the table name * @return object */ - public function _field_data($table) + function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -397,12 +412,13 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This public function escapes column and table names + * This function escapes column and table names * + * @access private * @param string * @return string */ - protected function _escape_identifiers($item) + function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -438,13 +454,14 @@ class CI_DB_sqlite_driver extends CI_DB { /** * From Tables * - * This public function implicitly groups FROM tables so there is no confusion + * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * + * @access public * @param type * @return type */ - public function _from_tables($tables) + function _from_tables($tables) { if ( ! is_array($tables)) { @@ -461,12 +478,13 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -478,6 +496,7 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -485,7 +504,7 @@ class CI_DB_sqlite_driver extends CI_DB { * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -513,12 +532,13 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This public function maps to "DELETE FROM table" + * This function maps to "DELETE FROM table" * + * @access public * @param string the table name * @return string */ - public function _truncate($table) + function _truncate($table) { return $this->_delete($table); } @@ -530,12 +550,13 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * + * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -563,12 +584,13 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * + * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -587,14 +609,18 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Close DB Connection * + * @access public * @param resource * @return void */ - public function _close($conn_id) + function _close($conn_id) { @sqlite_close($conn_id); } + + } + /* End of file sqlite_driver.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 595d41968..7fc531463 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -43,7 +43,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the database name * @return bool */ - public function _create_database() + function _create_database() { // In SQLite, a database is created when you connect to the database. // We'll return TRUE so that an error isn't generated @@ -55,10 +55,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - protected function _drop_database($name) + function _drop_database($name) { if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) { @@ -75,6 +76,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { /** * Create Table * + * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -82,7 +84,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -184,9 +186,10 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * * Unsupported feature in SQLite * + * @access private * @return bool */ - protected function _drop_table($table) + function _drop_table($table) { if ($this->db->db_debug) { @@ -203,6 +206,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -212,7 +216,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -257,11 +261,12 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -269,4 +274,4 @@ class CI_DB_sqlite_forge extends CI_DB_forge { } /* End of file sqlite_forge.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php index beb4db6cd..ac2235cbc 100644 --- a/system/database/drivers/sqlite/sqlite_result.php +++ b/system/database/drivers/sqlite/sqlite_result.php @@ -41,9 +41,10 @@ class CI_DB_sqlite_result extends CI_DB_result { /** * Number of rows in the result set * + * @access public * @return integer */ - public function num_rows() + function num_rows() { return @sqlite_num_rows($this->result_id); } @@ -53,9 +54,10 @@ class CI_DB_sqlite_result extends CI_DB_result { /** * Number of fields in the result set * + * @access public * @return integer */ - public function num_fields() + function num_fields() { return @sqlite_num_fields($this->result_id); } @@ -67,9 +69,10 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Generates an array of column names * + * @access public * @return array */ - public function list_fields() + function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -87,9 +90,10 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * + * @access public * @return array */ - public function field_data() + function field_data() { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -114,7 +118,7 @@ class CI_DB_sqlite_result extends CI_DB_result { * * @return null */ - public function free_result() + function free_result() { // Not implemented in SQLite } @@ -128,9 +132,10 @@ class CI_DB_sqlite_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * + * @access private * @return array */ - protected function _data_seek($n = 0) + function _data_seek($n = 0) { return sqlite_seek($this->result_id, $n); } @@ -142,9 +147,10 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Returns the result set as an array * + * @access private * @return array */ - protected function _fetch_assoc() + function _fetch_assoc() { return sqlite_fetch_array($this->result_id); } @@ -156,9 +162,10 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Returns the result set as an object * + * @access private * @return object */ - protected function _fetch_object() + function _fetch_object() { if (function_exists('sqlite_fetch_object')) { @@ -176,7 +183,9 @@ class CI_DB_sqlite_result extends CI_DB_result { } } } + } + /* End of file sqlite_result.php */ /* Location: ./system/database/drivers/sqlite/sqlite_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index c07004c54..9f9ddca44 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -94,4 +94,4 @@ class CI_DB_sqlite_utility extends CI_DB_utility { } /* End of file sqlite_utility.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file +/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ -- cgit v1.2.3-24-g4f1b From 99c02ef1dfbdfb444e3effb58906c4369f17b20e Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:06:16 -0400 Subject: Revert "Postgre visibility declarations" This reverts commit 7a3f89716a5ea3fc00e69342f8c9c7de77ca99ce. --- system/database/drivers/postgre/postgre_driver.php | 83 ++++++++++++++-------- system/database/drivers/postgre/postgre_forge.php | 24 ++++--- system/database/drivers/postgre/postgre_result.php | 25 ++++--- .../database/drivers/postgre/postgre_utility.php | 4 +- 4 files changed, 86 insertions(+), 50 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 6ef83726a..fad9539ff 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -42,28 +42,29 @@ */ class CI_DB_postgre_driver extends CI_DB { - public $dbdriver = 'postgre'; + var $dbdriver = 'postgre'; - protected $_escape_char = '"'; + var $_escape_char = '"'; // clause and character used for LIKE escape sequences - protected $_like_escape_str = " ESCAPE '%s' "; - protected $_like_escape_chr = '!'; + var $_like_escape_str = " ESCAPE '%s' "; + var $_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. */ - protected $_count_string = "SELECT COUNT(*) AS "; - protected $_random_keyword = ' RANDOM()'; // database specific random keyword + var $_count_string = "SELECT COUNT(*) AS "; + var $_random_keyword = ' RANDOM()'; // database specific random keyword /** * Connection String * + * @access private * @return string */ - protected function _connect_string() + function _connect_string() { $components = array( 'hostname' => 'host', @@ -89,9 +90,10 @@ class CI_DB_postgre_driver extends CI_DB { /** * Non-persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_connect() + function db_connect() { return @pg_connect($this->_connect_string()); } @@ -101,9 +103,10 @@ class CI_DB_postgre_driver extends CI_DB { /** * Persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_pconnect() + function db_pconnect() { return @pg_pconnect($this->_connect_string()); } @@ -116,9 +119,10 @@ class CI_DB_postgre_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * + * @access public * @return void */ - public function reconnect() + function reconnect() { if (pg_ping($this->conn_id) === FALSE) { @@ -131,9 +135,10 @@ class CI_DB_postgre_driver extends CI_DB { /** * Select the database * + * @access private called by the base class * @return resource */ - protected function db_select() + function db_select() { // Not needed for Postgre so we'll return TRUE return TRUE; @@ -186,10 +191,11 @@ class CI_DB_postgre_driver extends CI_DB { /** * Execute the query * + * @access private called by the base class * @param string an SQL query * @return resource */ - protected function _execute($sql) + function _execute($sql) { return @pg_query($this->conn_id, $sql); } @@ -258,11 +264,12 @@ class CI_DB_postgre_driver extends CI_DB { /** * Escape String * + * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - public function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -292,9 +299,10 @@ class CI_DB_postgre_driver extends CI_DB { /** * Affected Rows * + * @access public * @return integer */ - public function affected_rows() + function affected_rows() { return @pg_affected_rows($this->result_id); } @@ -304,9 +312,10 @@ class CI_DB_postgre_driver extends CI_DB { /** * Insert ID * + * @access public * @return integer */ - public function insert_id() + function insert_id() { $v = $this->version(); @@ -346,10 +355,11 @@ class CI_DB_postgre_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * + * @access public * @param string * @return string */ - public function count_all($table = '') + function count_all($table = '') { if ($table == '') { @@ -374,10 +384,11 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * + * @access private * @param boolean * @return string */ - protected function _list_tables($prefix_limit = FALSE) + function _list_tables($prefix_limit = FALSE) { $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; @@ -396,10 +407,11 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * + * @access public * @param string the table name * @return string */ - public function _list_columns($table = '') + function _list_columns($table = '') { return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'"; } @@ -411,10 +423,11 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * + * @access public * @param string the table name * @return object */ - public function _field_data($table) + function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -441,10 +454,11 @@ class CI_DB_postgre_driver extends CI_DB { * * This function escapes column and table names * + * @access private * @param string * @return string */ - protected function _escape_identifiers($item) + function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -483,10 +497,11 @@ class CI_DB_postgre_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * + * @access public * @param type * @return type */ - public function _from_tables($tables) + function _from_tables($tables) { if ( ! is_array($tables)) { @@ -503,12 +518,13 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -520,12 +536,13 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert_batch($table, $keys, $values) + function _insert_batch($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); } @@ -537,6 +554,7 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -544,7 +562,7 @@ class CI_DB_postgre_driver extends CI_DB { * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -567,10 +585,11 @@ class CI_DB_postgre_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * + * @access public * @param string the table name * @return string */ - public function _truncate($table) + function _truncate($table) { return "TRUNCATE ".$table; } @@ -582,12 +601,13 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * + * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -612,12 +632,13 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * + * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + function _limit($sql, $limit, $offset) { $sql .= "LIMIT ".$limit; @@ -634,14 +655,18 @@ class CI_DB_postgre_driver extends CI_DB { /** * Close DB Connection * + * @access public * @param resource * @return void */ - public function _close($conn_id) + function _close($conn_id) { @pg_close($conn_id); } + + } + /* End of file postgre_driver.php */ -/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/postgre/postgre_driver.php */ diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 2aa6ee82a..577100544 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -39,10 +39,11 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Create database * + * @access private * @param string the database name * @return bool */ - protected function _create_database($name) + function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -52,10 +53,11 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - protected function _drop_database($name) + function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -68,7 +70,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - protected function _process_fields($fields, $primary_keys=array()) + function _process_fields($fields, $primary_keys=array()) { $sql = ''; $current_field_count = 0; @@ -175,6 +177,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Create Table * + * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -182,7 +185,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -238,11 +241,8 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Drop Table - * - * @param string the table name - * @return string */ - protected function _drop_table($table) + function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE"; } @@ -255,6 +255,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -264,7 +265,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $fields, $after_field = '') + function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -291,15 +292,16 @@ class CI_DB_postgre_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } /* End of file postgre_forge.php */ -/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/postgre/postgre_forge.php */ diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index b27afaedb..12d7547c5 100644 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.php @@ -41,9 +41,10 @@ class CI_DB_postgre_result extends CI_DB_result { /** * Number of rows in the result set * + * @access public * @return integer */ - public function num_rows() + function num_rows() { return @pg_num_rows($this->result_id); } @@ -53,9 +54,10 @@ class CI_DB_postgre_result extends CI_DB_result { /** * Number of fields in the result set * + * @access public * @return integer */ - public function num_fields() + function num_fields() { return @pg_num_fields($this->result_id); } @@ -67,9 +69,10 @@ class CI_DB_postgre_result extends CI_DB_result { * * Generates an array of column names * + * @access public * @return array */ - public function list_fields() + function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -87,9 +90,10 @@ class CI_DB_postgre_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * + * @access public * @return array */ - public function field_data() + function field_data() { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -114,7 +118,7 @@ class CI_DB_postgre_result extends CI_DB_result { * * @return null */ - public function free_result() + function free_result() { if (is_resource($this->result_id)) { @@ -132,9 +136,10 @@ class CI_DB_postgre_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * + * @access private * @return array */ - protected function _data_seek($n = 0) + function _data_seek($n = 0) { return pg_result_seek($this->result_id, $n); } @@ -146,9 +151,10 @@ class CI_DB_postgre_result extends CI_DB_result { * * Returns the result set as an array * + * @access private * @return array */ - protected function _fetch_assoc() + function _fetch_assoc() { return pg_fetch_assoc($this->result_id); } @@ -160,13 +166,16 @@ class CI_DB_postgre_result extends CI_DB_result { * * Returns the result set as an object * + * @access private * @return object */ - protected function _fetch_object() + function _fetch_object() { return pg_fetch_object($this->result_id); } + } + /* End of file postgre_result.php */ /* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index cf29201ff..e31a6db8f 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -78,7 +78,7 @@ class CI_DB_postgre_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - public function _backup($params = array()) + function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); @@ -86,4 +86,4 @@ class CI_DB_postgre_utility extends CI_DB_utility { } /* End of file postgre_utility.php */ -/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file +/* Location: ./system/database/drivers/postgre/postgre_utility.php */ -- cgit v1.2.3-24-g4f1b From 667c9feadee8ef5ea8c1859e7c79c2d116469051 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:06:34 -0400 Subject: Revert "PDO driver access modifiers" This reverts commit 8c332e7f907e6af498f18fa1bf28e0a0c6e11448. --- system/database/drivers/pdo/pdo_driver.php | 124 +++++++++++++++++----------- system/database/drivers/pdo/pdo_result.php | 25 ++++-- system/database/drivers/pdo/pdo_utility.php | 12 ++- 3 files changed, 98 insertions(+), 63 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 727f097f8..658a3d5a0 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -42,31 +42,28 @@ */ class CI_DB_pdo_driver extends CI_DB { - public $dbdriver = 'pdo'; + var $dbdriver = 'pdo'; // the character used to excape - not necessary for PDO - protected $_escape_char = ''; + var $_escape_char = ''; // clause and character used for LIKE escape sequences - protected $_like_escape_str; - protected $_like_escape_chr; + var $_like_escape_str; + var $_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() public functions. + * used for the count_all() and count_all_results() functions. */ - protected $_count_string = "SELECT COUNT(*) AS "; - protected $_random_keyword; + var $_count_string = "SELECT COUNT(*) AS "; + var $_random_keyword; // need to track the pdo driver and options - protected $pdodriver; - protected $options = array(); + var $pdodriver; + var $options = array(); - /** - * Pre-connection setup - */ - public function __construct($params) + function __construct($params) { parent::__construct($params); @@ -107,10 +104,11 @@ class CI_DB_pdo_driver extends CI_DB { /** * Connection String * + * @access private * @param array * @return void */ - protected function _connect_string($params) + function _connect_string($params) { if (strpos($this->hostname, ':')) { @@ -192,9 +190,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Non-persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_connect() + function db_connect() { $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; @@ -206,9 +205,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_pconnect() + function db_pconnect() { $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; $this->options[PDO::ATTR_PERSISTENT] = TRUE; @@ -221,9 +221,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * PDO connection * + * @access private called by the PDO driver class * @return resource */ - protected function pdo_connect() + function pdo_connect() { // Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php if ($this->pdodriver == 'mysql' && is_php('5.3.6')) @@ -257,9 +258,10 @@ class CI_DB_pdo_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * + * @access public * @return void */ - public function reconnect() + function reconnect() { if ($this->db->db_debug) { @@ -274,9 +276,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Select the database * + * @access private called by the base class * @return resource */ - protected function db_select() + function db_select() { // Not needed for PDO return TRUE; @@ -301,10 +304,11 @@ class CI_DB_pdo_driver extends CI_DB { /** * Execute the query * + * @access private called by the base class * @param string an SQL query * @return object */ - protected function _execute($sql) + function _execute($sql) { $sql = $this->_prep_query($sql); @@ -329,10 +333,11 @@ class CI_DB_pdo_driver extends CI_DB { * * If needed, each database adapter can prep the query string * + * @access private called by execute() * @param string an SQL query * @return string */ - protected function _prep_query($sql) + function _prep_query($sql) { if ($this->pdodriver === 'pgsql') { @@ -342,7 +347,7 @@ class CI_DB_pdo_driver extends CI_DB { elseif ($this->pdodriver === 'sqlite') { // Change the backtick(s) for SQLite - $sql = str_replace('`', '"', $sql); + $sql = str_replace('`', '', $sql); } return $sql; @@ -353,9 +358,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Begin Transaction * + * @access public * @return bool */ - public function trans_begin($test_mode = FALSE) + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -381,9 +387,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Commit Transaction * + * @access public * @return bool */ - public function trans_commit() + function trans_commit() { if ( ! $this->trans_enabled) { @@ -406,9 +413,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Rollback Transaction * + * @access public * @return bool */ - public function trans_rollback() + function trans_rollback() { if ( ! $this->trans_enabled) { @@ -431,11 +439,12 @@ class CI_DB_pdo_driver extends CI_DB { /** * Escape String * + * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - public function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -474,9 +483,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Affected Rows * + * @access public * @return integer */ - public function affected_rows() + function affected_rows() { return $this->affect_rows; } @@ -508,10 +518,11 @@ class CI_DB_pdo_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * + * @access public * @param string * @return string */ - public function count_all($table = '') + function count_all($table = '') { if ($table == '') { @@ -539,19 +550,20 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * + * @access private * @param boolean * @return string */ - protected function _list_tables($prefix_limit = FALSE) + function _list_tables($prefix_limit = FALSE) { if ($this->pdodriver == 'pgsql') { - // Analog public function to show all tables in postgre + // Analog function to show all tables in postgre $sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"; } elseif ($this->pdodriver == 'sqlite') { - // Analog public function to show all tables in sqlite + // Analog function to show all tables in sqlite $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"; } else @@ -574,10 +586,11 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * + * @access public * @param string the table name * @return string */ - public function _list_columns($table = '') + function _list_columns($table = '') { return 'SHOW COLUMNS FROM '.$this->_from_tables($table); } @@ -589,24 +602,25 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * + * @access public * @param string the table name * @return object */ - public function _field_data($table) + function _field_data($table) { if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql') { - // Analog public function for mysql and postgre + // Analog function for mysql and postgre return 'SELECT * FROM '.$this->_from_tables($table).' LIMIT 1'; } elseif ($this->pdodriver == 'oci') { - // Analog public function for oci + // Analog function for oci return 'SELECT * FROM '.$this->_from_tables($table).' WHERE ROWNUM <= 1'; } elseif ($this->pdodriver == 'sqlite') { - // Analog public function for sqlite + // Analog function for sqlite return 'PRAGMA table_info('.$this->_from_tables($table).')'; } @@ -647,12 +661,13 @@ class CI_DB_pdo_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This public function escapes column and table names + * This function escapes column and table names * + * @access private * @param string * @return string */ - protected function _escape_identifiers($item) + function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -689,13 +704,14 @@ class CI_DB_pdo_driver extends CI_DB { /** * From Tables * - * This public function implicitly groups FROM tables so there is no confusion + * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * + * @access public * @param type * @return type */ - public function _from_tables($tables) + function _from_tables($tables) { if ( ! is_array($tables)) { @@ -712,12 +728,13 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + function _insert($table, $keys, $values) { return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } @@ -729,12 +746,13 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert_batch($table, $keys, $values) + function _insert_batch($table, $keys, $values) { return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES '.implode(', ', $values); } @@ -746,6 +764,7 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -753,7 +772,7 @@ class CI_DB_pdo_driver extends CI_DB { * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -777,12 +796,13 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific batch update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause * @return string */ - public function _update_batch($table, $values, $index, $where = NULL) + function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); $where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; @@ -829,12 +849,13 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This public function maps to "DELETE FROM table" + * This function maps to "DELETE FROM table" * + * @access public * @param string the table name * @return string */ - public function _truncate($table) + function _truncate($table) { return $this->_delete($table); } @@ -846,12 +867,13 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * + * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -880,12 +902,13 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * + * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + function _limit($sql, $limit, $offset) { if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite') { @@ -907,10 +930,11 @@ class CI_DB_pdo_driver extends CI_DB { /** * Close DB Connection * + * @access public * @param resource * @return void */ - public function _close($conn_id) + function _close($conn_id) { $this->conn_id = null; } @@ -918,4 +942,4 @@ class CI_DB_pdo_driver extends CI_DB { } /* End of file pdo_driver.php */ -/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/pdo/pdo_driver.php */ diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 330a2e677..384b753da 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -51,9 +51,10 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Number of rows in the result set * + * @access public * @return integer */ - public function num_rows() + function num_rows() { if (empty($this->result_id) OR ! is_object($this->result_id)) { @@ -73,9 +74,10 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Fetch the result handler * + * @access public * @return mixed */ - public function result_assoc() + function result_assoc() { // If the result already fetched before, use that one if (count($this->result_array) > 0 OR $this->is_fetched) @@ -114,9 +116,10 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Number of fields in the result set * + * @access public * @return integer */ - public function num_fields() + function num_fields() { return $this->result_id->columnCount(); } @@ -128,9 +131,10 @@ class CI_DB_pdo_result extends CI_DB_result { * * Generates an array of column names * + * @access public * @return array */ - public function list_fields() + function list_fields() { if ($this->db->db_debug) { @@ -147,9 +151,10 @@ class CI_DB_pdo_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * + * @access public * @return array */ - public function field_data() + function field_data() { $data = array(); @@ -219,7 +224,7 @@ class CI_DB_pdo_result extends CI_DB_result { * * @return null */ - public function free_result() + function free_result() { if (is_object($this->result_id)) { @@ -236,9 +241,10 @@ class CI_DB_pdo_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * + * @access private * @return array */ - protected function _data_seek($n = 0) + function _data_seek($n = 0) { return FALSE; } @@ -250,9 +256,10 @@ class CI_DB_pdo_result extends CI_DB_result { * * Returns the result set as an array * + * @access private * @return array */ - protected function _fetch_assoc() + function _fetch_assoc() { return $this->result_id->fetch(PDO::FETCH_ASSOC); } @@ -267,7 +274,7 @@ class CI_DB_pdo_result extends CI_DB_result { * @access private * @return object */ - protected function _fetch_object() + function _fetch_object() { return $this->result_id->fetchObject(); } diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php index 2c12d7438..c278c5172 100644 --- a/system/database/drivers/pdo/pdo_utility.php +++ b/system/database/drivers/pdo/pdo_utility.php @@ -39,9 +39,10 @@ class CI_DB_pdo_utility extends CI_DB_utility { /** * List databases * + * @access private * @return bool */ - protected function _list_databases() + function _list_databases() { // Not sure if PDO lets you list all databases... if ($this->db->db_debug) @@ -58,10 +59,11 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * + * @access private * @param string the table name * @return object */ - protected function _optimize_table($table) + function _optimize_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -78,10 +80,11 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * + * @access private * @param string the table name * @return object */ - protected function _repair_table($table) + function _repair_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -96,10 +99,11 @@ class CI_DB_pdo_utility extends CI_DB_utility { /** * PDO Export * + * @access private * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 9e560a4c4828901a562f5459157ba0f76612c34f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:06:46 -0400 Subject: Revert "ODBC access modifiers" This reverts commit 142ca8e565b722b758b5ef88c888891d04da8700. --- system/database/drivers/odbc/odbc_driver.php | 96 ++++++++++++++++----------- system/database/drivers/odbc/odbc_forge.php | 20 ++++-- system/database/drivers/odbc/odbc_result.php | 19 ++++-- system/database/drivers/odbc/odbc_utility.php | 12 ++-- 4 files changed, 92 insertions(+), 55 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 78acd2ce9..58da07818 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -48,35 +48,32 @@ class CI_DB_odbc_driver extends CI_DB { var $_escape_char = ''; // clause and character used for LIKE escape sequences - protected $_like_escape_str = " {escape '%s'} "; - protected $_like_escape_chr = '!'; + var $_like_escape_str = " {escape '%s'} "; + var $_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() public functions. + * used for the count_all() and count_all_results() functions. */ - protected $_count_string = "SELECT COUNT(*) AS "; - protected $_random_keyword; + var $_count_string = "SELECT COUNT(*) AS "; + var $_random_keyword; - /** - * Constructor, to define random keyword - */ - public function __construct($params) + + function __construct($params) { parent::__construct($params); $this->_random_keyword = ' RND('.time().')'; // database specific random keyword } - - // -------------------------------------------------------------------------- /** * Non-persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_connect() + function db_connect() { return @odbc_connect($this->hostname, $this->username, $this->password); } @@ -86,9 +83,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_pconnect() + function db_pconnect() { return @odbc_pconnect($this->hostname, $this->username, $this->password); } @@ -101,9 +99,10 @@ class CI_DB_odbc_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * + * @access public * @return void */ - public function reconnect() + function reconnect() { // not implemented in odbc } @@ -113,9 +112,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Select the database * + * @access private called by the base class * @return resource */ - protected function db_select() + function db_select() { // Not needed for ODBC return TRUE; @@ -126,10 +126,11 @@ class CI_DB_odbc_driver extends CI_DB { /** * Execute the query * + * @access private called by the base class * @param string an SQL query * @return resource */ - protected function _execute($sql) + function _execute($sql) { return @odbc_exec($this->conn_id, $sql); } @@ -139,9 +140,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Begin Transaction * + * @access public * @return bool */ - public function trans_begin($test_mode = FALSE) + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -167,9 +169,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Commit Transaction * + * @access public * @return bool */ - public function trans_commit() + function trans_commit() { if ( ! $this->trans_enabled) { @@ -192,9 +195,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Rollback Transaction * + * @access public * @return bool */ - public function trans_rollback() + function trans_rollback() { if ( ! $this->trans_enabled) { @@ -217,11 +221,12 @@ class CI_DB_odbc_driver extends CI_DB { /** * Escape String * + * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - public function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -252,9 +257,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Affected Rows * + * @access public * @return integer */ - public function affected_rows() + function affected_rows() { return @odbc_num_rows($this->conn_id); } @@ -279,10 +285,11 @@ class CI_DB_odbc_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * + * @access public * @param string * @return string */ - public function count_all($table = '') + function count_all($table = '') { if ($table == '') { @@ -308,10 +315,11 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * + * @access private * @param boolean * @return string */ - protected function _list_tables($prefix_limit = FALSE) + function _list_tables($prefix_limit = FALSE) { $sql = "SHOW TABLES FROM `".$this->database."`"; @@ -331,10 +339,11 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * + * @access public * @param string the table name * @return string */ - public function _list_columns($table = '') + function _list_columns($table = '') { return "SHOW COLUMNS FROM ".$table; } @@ -346,10 +355,11 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * + * @access public * @param string the table name * @return object */ - public function _field_data($table) + function _field_data($table) { return "SELECT TOP 1 FROM ".$table; } @@ -374,12 +384,13 @@ class CI_DB_odbc_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This public function escapes column and table names + * This function escapes column and table names * + * @access private * @param string * @return string */ - protected function _escape_identifiers($item) + function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -415,13 +426,14 @@ class CI_DB_odbc_driver extends CI_DB { /** * From Tables * - * This public function implicitly groups FROM tables so there is no confusion + * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * + * @access public * @param type * @return type */ - public function _from_tables($tables) + function _from_tables($tables) { if ( ! is_array($tables)) { @@ -438,12 +450,13 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -455,6 +468,7 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -462,7 +476,7 @@ class CI_DB_odbc_driver extends CI_DB { * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -490,12 +504,13 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This public function maps to "DELETE FROM table" + * This function maps to "DELETE FROM table" * + * @access public * @param string the table name * @return string */ - public function _truncate($table) + function _truncate($table) { return $this->_delete($table); } @@ -507,12 +522,13 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * + * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -540,12 +556,13 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * + * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + function _limit($sql, $limit, $offset) { // Does ODBC doesn't use the LIMIT clause? return $sql; @@ -556,14 +573,19 @@ class CI_DB_odbc_driver extends CI_DB { /** * Close DB Connection * + * @access public * @param resource * @return void */ - public function _close($conn_id) + function _close($conn_id) { @odbc_close($conn_id); } + + } + + /* End of file odbc_driver.php */ -/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/odbc/odbc_driver.php */ diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index 121c09606..acc2cadee 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -39,10 +39,11 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Create database * + * @access private * @param string the database name * @return bool */ - protected function _create_database() + function _create_database() { // ODBC has no "create database" command since it's // designed to connect to an existing database @@ -58,10 +59,11 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - protected function _drop_database($name) + function _drop_database($name) { // ODBC has no "drop database" command since it's // designed to connect to an existing database @@ -77,6 +79,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Create Table * + * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -84,7 +87,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -183,9 +186,10 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Drop Table * + * @access private * @return bool */ - protected function _drop_table($table) + function _drop_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -203,6 +207,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -212,7 +217,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -255,11 +260,12 @@ class CI_DB_odbc_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -267,4 +273,4 @@ class CI_DB_odbc_forge extends CI_DB_forge { } /* End of file odbc_forge.php */ -/* Location: ./system/database/drivers/odbc/odbc_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/odbc/odbc_forge.php */ diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index 0b74871e0..d19fa247e 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -130,7 +130,7 @@ class CI_DB_odbc_result extends CI_DB_result { * * @return null */ - public function free_result() + function free_result() { if (is_resource($this->result_id)) { @@ -148,9 +148,10 @@ class CI_DB_odbc_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * + * @access private * @return array */ - protected function _data_seek($n = 0) + function _data_seek($n = 0) { return FALSE; } @@ -162,9 +163,10 @@ class CI_DB_odbc_result extends CI_DB_result { * * Returns the result set as an array * + * @access private * @return array */ - protected function _fetch_assoc() + function _fetch_assoc() { if (function_exists('odbc_fetch_object')) { @@ -183,9 +185,10 @@ class CI_DB_odbc_result extends CI_DB_result { * * Returns the result set as an object * + * @access private * @return object */ - protected function _fetch_object() + function _fetch_object() { if (function_exists('odbc_fetch_object')) { @@ -204,9 +207,10 @@ class CI_DB_odbc_result extends CI_DB_result { * subsititutes the odbc_fetch_object function when * not available (odbc_fetch_object requires unixODBC) * + * @access private * @return object */ - protected function _odbc_fetch_object(& $odbc_result) { + function _odbc_fetch_object(& $odbc_result) { $rs = array(); $rs_obj = FALSE; if (odbc_fetch_into($odbc_result, $rs)) { @@ -225,9 +229,10 @@ class CI_DB_odbc_result extends CI_DB_result { * subsititutes the odbc_fetch_array function when * not available (odbc_fetch_array requires unixODBC) * + * @access private * @return array */ - protected function _odbc_fetch_array(& $odbc_result) { + function _odbc_fetch_array(& $odbc_result) { $rs = array(); $rs_assoc = FALSE; if (odbc_fetch_into($odbc_result, $rs)) { @@ -313,4 +318,4 @@ class CI_DB_odbc_result extends CI_DB_result { } /* End of file odbc_result.php */ -/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file +/* Location: ./system/database/drivers/odbc/odbc_result.php */ diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index d663da1ad..c146c1785 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -39,9 +39,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * List databases * + * @access private * @return bool */ - protected function _list_databases() + function _list_databases() { // Not sure if ODBC lets you list all databases... if ($this->db->db_debug) @@ -58,10 +59,11 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * + * @access private * @param string the table name * @return object */ - protected function _optimize_table($table) + function _optimize_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -78,10 +80,11 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * + * @access private * @param string the table name * @return object */ - protected function _repair_table($table) + function _repair_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -96,10 +99,11 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * ODBC Export * + * @access private * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 48e1d2e78efea9f41e5ae65b600d35bb87b2e40f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:07:07 -0400 Subject: Revert "Oci8 access modifiers" This reverts commit 9f86f5cddea54e7fedf4be89d1d1cc90d1564488. --- system/database/drivers/oci8/oci8_driver.php | 26 ++++++++++++++------------ system/database/drivers/oci8/oci8_forge.php | 17 +++++++++++------ system/database/drivers/oci8/oci8_result.php | 3 ++- system/database/drivers/oci8/oci8_utility.php | 12 ++++++++---- 4 files changed, 35 insertions(+), 23 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index e7b744bd3..8d7040618 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -53,33 +53,33 @@ class CI_DB_oci8_driver extends CI_DB { - public $dbdriver = 'oci8'; + var $dbdriver = 'oci8'; // The character used for excaping - public $_escape_char = '"'; + var $_escape_char = '"'; // clause and character used for LIKE escape sequences - public $_like_escape_str = " escape '%s' "; - public $_like_escape_chr = '!'; + var $_like_escape_str = " escape '%s' "; + var $_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. */ - public $_count_string = "SELECT COUNT(1) AS "; - public $_random_keyword = ' ASC'; // not currently supported + var $_count_string = "SELECT COUNT(1) AS "; + var $_random_keyword = ' ASC'; // not currently supported // Set "auto commit" by default - public $_commit = OCI_COMMIT_ON_SUCCESS; + var $_commit = OCI_COMMIT_ON_SUCCESS; // need to track statement id and cursor id - public $stmt_id; - public $curs_id; + var $stmt_id; + var $curs_id; // if we use a limit, we will add a field that will // throw off num_fields later - public $limit_used; + var $limit_used; /** * Non-persistent database connection @@ -214,7 +214,7 @@ class CI_DB_oci8_driver extends CI_DB { * KEY OPTIONAL NOTES * name no the name of the parameter should be in : format * value no the value of the parameter. If this is an OUT or IN OUT parameter, - * this should be a reference to a publiciable + * this should be a reference to a variable * type yes the type of the parameter * length yes the max size of the parameter */ @@ -781,5 +781,7 @@ class CI_DB_oci8_driver extends CI_DB { } + + /* End of file oci8_driver.php */ -/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/oci8/oci8_driver.php */ diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index f9a90ff0a..7fcc8094d 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -39,10 +39,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Create database * + * @access public * @param string the database name * @return bool */ - public function _create_database($name) + function _create_database($name) { return FALSE; } @@ -52,10 +53,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - protected function _drop_database($name) + function _drop_database($name) { return FALSE; } @@ -142,9 +144,10 @@ class CI_DB_oci8_forge extends CI_DB_forge { /** * Drop Table * + * @access private * @return bool */ - protected function _drop_table($table) + function _drop_table($table) { return FALSE; } @@ -157,6 +160,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -166,7 +170,7 @@ class CI_DB_oci8_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -208,11 +212,12 @@ class CI_DB_oci8_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } @@ -220,4 +225,4 @@ class CI_DB_oci8_forge extends CI_DB_forge { } /* End of file oci8_forge.php */ -/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/oci8/oci8_forge.php */ diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index a14e32eec..6f1b8b4c1 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -235,5 +235,6 @@ class CI_DB_oci8_result extends CI_DB_result { } + /* End of file oci8_result.php */ -/* Location: ./system/database/drivers/oci8/oci8_result.php */ \ No newline at end of file +/* Location: ./system/database/drivers/oci8/oci8_result.php */ diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index f4863c0db..62dfb2f3c 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -39,9 +39,10 @@ class CI_DB_oci8_utility extends CI_DB_utility { /** * List databases * + * @access private * @return bool */ - protected function _list_databases() + function _list_databases() { return FALSE; } @@ -53,10 +54,11 @@ class CI_DB_oci8_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * + * @access private * @param string the table name * @return object */ - protected function _optimize_table($table) + function _optimize_table($table) { return FALSE; // Is this supported in Oracle? } @@ -68,10 +70,11 @@ class CI_DB_oci8_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * + * @access private * @param string the table name * @return object */ - protected function _repair_table($table) + function _repair_table($table) { return FALSE; // Is this supported in Oracle? } @@ -81,10 +84,11 @@ class CI_DB_oci8_utility extends CI_DB_utility { /** * Oracle Export * + * @access private * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 8c1b2dc39d104774b3a7be87dc41f2b702bb883c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:07:18 -0400 Subject: Revert "Added access modifiers for MSSQL driver" This reverts commit ba1ebbefa9c5d225fa28c76dac276e6120263a25. --- system/database/drivers/mssql/mssql_driver.php | 81 ++++++++++++++++--------- system/database/drivers/mssql/mssql_forge.php | 20 +++--- system/database/drivers/mssql/mssql_result.php | 24 +++++--- system/database/drivers/mssql/mssql_utility.php | 12 ++-- 4 files changed, 90 insertions(+), 47 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 9448f052c..a93ac57fe 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -62,9 +62,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Non-persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_connect() + function db_connect() { if ($this->port != '') { @@ -79,9 +80,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_pconnect() + function db_pconnect() { if ($this->port != '') { @@ -99,9 +101,10 @@ class CI_DB_mssql_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * + * @access public * @return void */ - public function reconnect() + function reconnect() { // not implemented in MSSQL } @@ -137,10 +140,11 @@ class CI_DB_mssql_driver extends CI_DB { /** * Execute the query * + * @access private called by the base class * @param string an SQL query * @return resource */ - protected function _execute($sql) + function _execute($sql) { return @mssql_query($sql, $this->conn_id); } @@ -150,9 +154,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Begin Transaction * + * @access public * @return bool */ - public function trans_begin($test_mode = FALSE) + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -179,9 +184,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Commit Transaction * + * @access public * @return bool */ - public function trans_commit() + function trans_commit() { if ( ! $this->trans_enabled) { @@ -203,9 +209,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Rollback Transaction * + * @access public * @return bool */ - public function trans_rollback() + function trans_rollback() { if ( ! $this->trans_enabled) { @@ -227,11 +234,12 @@ class CI_DB_mssql_driver extends CI_DB { /** * Escape String * + * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - public function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -264,9 +272,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Affected Rows * + * @access public * @return integer */ - public function affected_rows() + function affected_rows() { return @mssql_rows_affected($this->conn_id); } @@ -278,9 +287,10 @@ class CI_DB_mssql_driver extends CI_DB { * * Returns the last id created in the Identity column. * + * @access public * @return integer */ - public function insert_id() + function insert_id() { $ver = self::_parse_major_version($this->version()); $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id"); @@ -297,10 +307,11 @@ class CI_DB_mssql_driver extends CI_DB { * Grabs the major version number from the * database server version string passed in. * + * @access private * @param string $version * @return int16 major version number */ - protected function _parse_major_version($version) + function _parse_major_version($version) { preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); return $ver_info[1]; // return the major version b/c that's all we're interested in. @@ -313,7 +324,7 @@ class CI_DB_mssql_driver extends CI_DB { * * @return string */ - protected public function _version() + protected function _version() { return 'SELECT @@VERSION AS ver'; } @@ -326,10 +337,11 @@ class CI_DB_mssql_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * + * @access public * @param string * @return string */ - public function count_all($table = '') + function count_all($table = '') { if ($table == '') { @@ -354,10 +366,11 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * + * @access private * @param boolean * @return string */ - protected function _list_tables($prefix_limit = FALSE) + function _list_tables($prefix_limit = FALSE) { $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; @@ -378,10 +391,11 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * + * @access private * @param string the table name * @return string */ - protected function _list_columns($table = '') + function _list_columns($table = '') { return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'"; } @@ -393,10 +407,11 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * + * @access public * @param string the table name * @return object */ - public function _field_data($table) + function _field_data($table) { return "SELECT TOP 1 * FROM ".$table; } @@ -423,12 +438,13 @@ class CI_DB_mssql_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This public function escapes column and table names + * This function escapes column and table names * + * @access private * @param string * @return string */ - protected function _escape_identifiers($item) + function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -464,13 +480,14 @@ class CI_DB_mssql_driver extends CI_DB { /** * From Tables * - * This public function implicitly groups FROM tables so there is no confusion + * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * + * @access public * @param type * @return type */ - public function _from_tables($tables) + function _from_tables($tables) { if ( ! is_array($tables)) { @@ -487,12 +504,13 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -504,6 +522,7 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -511,7 +530,7 @@ class CI_DB_mssql_driver extends CI_DB { * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -539,12 +558,13 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This public function maps to "DELETE FROM table" + * This function maps to "DELETE FROM table" * + * @access public * @param string the table name * @return string */ - public function _truncate($table) + function _truncate($table) { return "TRUNCATE ".$table; } @@ -556,12 +576,13 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * + * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -589,12 +610,13 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * + * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + function _limit($sql, $limit, $offset) { $i = $limit + $offset; @@ -606,15 +628,18 @@ class CI_DB_mssql_driver extends CI_DB { /** * Close DB Connection * + * @access public * @param resource * @return void */ - public function _close($conn_id) + function _close($conn_id) { @mssql_close($conn_id); } } + + /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index 500dd9845..4a8089bb1 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -39,10 +39,11 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Create database * + * @access private * @param string the database name * @return bool */ - protected function _create_database($name) + function _create_database($name) { return "CREATE DATABASE ".$name; } @@ -52,10 +53,11 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - protected function _drop_database($name) + function _drop_database($name) { return "DROP DATABASE ".$name; } @@ -65,9 +67,10 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Drop Table * + * @access private * @return bool */ - protected function _drop_table($table) + function _drop_table($table) { return "DROP TABLE ".$this->db->_escape_identifiers($table); } @@ -77,6 +80,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Create Table * + * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) @@ -84,7 +88,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -186,6 +190,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -195,7 +200,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -237,11 +242,12 @@ class CI_DB_mssql_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); @@ -250,4 +256,4 @@ class CI_DB_mssql_forge extends CI_DB_forge { } /* End of file mssql_forge.php */ -/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/mssql/mssql_forge.php */ diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index ff899406c..b205ce2d1 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -41,9 +41,10 @@ class CI_DB_mssql_result extends CI_DB_result { /** * Number of rows in the result set * + * @access public * @return integer */ - public function num_rows() + function num_rows() { return @mssql_num_rows($this->result_id); } @@ -53,9 +54,10 @@ class CI_DB_mssql_result extends CI_DB_result { /** * Number of fields in the result set * + * @access public * @return integer */ - public function num_fields() + function num_fields() { return @mssql_num_fields($this->result_id); } @@ -67,9 +69,10 @@ class CI_DB_mssql_result extends CI_DB_result { * * Generates an array of column names * + * @access public * @return array */ - public function list_fields() + function list_fields() { $field_names = array(); while ($field = mssql_fetch_field($this->result_id)) @@ -87,9 +90,10 @@ class CI_DB_mssql_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * + * @access public * @return array */ - public function field_data() + function field_data() { $retval = array(); while ($field = mssql_fetch_field($this->result_id)) @@ -114,7 +118,7 @@ class CI_DB_mssql_result extends CI_DB_result { * * @return null */ - public function free_result() + function free_result() { if (is_resource($this->result_id)) { @@ -132,9 +136,10 @@ class CI_DB_mssql_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * + * @access private * @return array */ - protected function _data_seek($n = 0) + function _data_seek($n = 0) { return mssql_data_seek($this->result_id, $n); } @@ -146,9 +151,10 @@ class CI_DB_mssql_result extends CI_DB_result { * * Returns the result set as an array * + * @access private * @return array */ - protected function _fetch_assoc() + function _fetch_assoc() { return mssql_fetch_assoc($this->result_id); } @@ -160,14 +166,16 @@ class CI_DB_mssql_result extends CI_DB_result { * * Returns the result set as an object * + * @access private * @return object */ - protected function _fetch_object() + function _fetch_object() { return mssql_fetch_object($this->result_id); } } + /* End of file mssql_result.php */ /* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index e64874132..28f34b999 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -39,9 +39,10 @@ class CI_DB_mssql_utility extends CI_DB_utility { /** * List databases * + * @access private * @return bool */ - protected function _list_databases() + function _list_databases() { return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases } @@ -53,10 +54,11 @@ class CI_DB_mssql_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * + * @access private * @param string the table name * @return object */ - protected function _optimize_table($table) + function _optimize_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -68,10 +70,11 @@ class CI_DB_mssql_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * + * @access private * @param string the table name * @return object */ - protected function _repair_table($table) + function _repair_table($table) { return FALSE; // Is this supported in MS SQL? } @@ -81,10 +84,11 @@ class CI_DB_mssql_utility extends CI_DB_utility { /** * MSSQL Export * + * @access private * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 0c2747151f0cd32b6188ecd8c1dcdcdb6fe44792 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:08:29 -0400 Subject: Revert "Added access modifiers to the rest of the Cubrid classes" This reverts commit f83f0d5448aadcf76fbdac363d0fe7ea811ca9bf. --- system/database/drivers/cubrid/cubrid_forge.php | 21 ++++++++++++++------- system/database/drivers/cubrid/cubrid_result.php | 23 +++++++++++++++-------- system/database/drivers/cubrid/cubrid_utility.php | 8 ++++---- 3 files changed, 33 insertions(+), 19 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 6bfc7c28f..7d606ea36 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -39,10 +39,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Create database * + * @access private * @param string the database name * @return bool */ - protected function _create_database($name) + function _create_database($name) { // CUBRID does not allow to create a database in SQL. The GUI tools // have to be used for this purpose. @@ -54,10 +55,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Drop database * + * @access private * @param string the database name * @return bool */ - protected function _drop_database($name) + function _drop_database($name) { // CUBRID does not allow to drop a database in SQL. The GUI tools // have to be used for this purpose. @@ -69,10 +71,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Process Fields * + * @access private * @param mixed the fields * @return string */ - protected function _process_fields($fields) + function _process_fields($fields) { $current_field_count = 0; $sql = ''; @@ -169,6 +172,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Create Table * + * @access private * @param string the table name * @param mixed the fields * @param mixed primary key(s) @@ -176,7 +180,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -228,9 +232,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Drop Table * + * @access private * @return string */ - protected function _drop_table($table) + function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table); } @@ -243,13 +248,14 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * + * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param array fields * @param string the field after which we should add the new field * @return object */ - protected function _alter_table($alter_type, $table, $fields, $after_field = '') + function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -276,11 +282,12 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * + * @access private * @param string the old table name * @param string the new table name * @return string */ - protected function _rename_table($table_name, $new_table_name) + function _rename_table($table_name, $new_table_name) { return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php index c7a7632aa..a7eeb8a39 100644 --- a/system/database/drivers/cubrid/cubrid_result.php +++ b/system/database/drivers/cubrid/cubrid_result.php @@ -41,9 +41,10 @@ class CI_DB_cubrid_result extends CI_DB_result { /** * Number of rows in the result set * + * @access public * @return integer */ - public function num_rows() + function num_rows() { return @cubrid_num_rows($this->result_id); } @@ -53,9 +54,10 @@ class CI_DB_cubrid_result extends CI_DB_result { /** * Number of fields in the result set * + * @access public * @return integer */ - public function num_fields() + function num_fields() { return @cubrid_num_fields($this->result_id); } @@ -67,9 +69,10 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Generates an array of column names * + * @access public * @return array */ - public function list_fields() + function list_fields() { return cubrid_column_names($this->result_id); } @@ -81,9 +84,10 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * + * @access public * @return array */ - public function field_data() + function field_data() { $retval = array(); @@ -145,7 +149,7 @@ class CI_DB_cubrid_result extends CI_DB_result { * * @return null */ - public function free_result() + function free_result() { if(is_resource($this->result_id) || get_resource_type($this->result_id) == "Unknown" && @@ -165,9 +169,10 @@ class CI_DB_cubrid_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * + * @access private * @return array */ - protected function _data_seek($n = 0) + function _data_seek($n = 0) { return cubrid_data_seek($this->result_id, $n); } @@ -179,9 +184,10 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Returns the result set as an array * + * @access private * @return array */ - protected function _fetch_assoc() + function _fetch_assoc() { return cubrid_fetch_assoc($this->result_id); } @@ -193,9 +199,10 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Returns the result set as an object * + * @access private * @return object */ - protected function _fetch_object() + function _fetch_object() { return cubrid_fetch_object($this->result_id); } diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php index de28e6335..a13c0a5e4 100644 --- a/system/database/drivers/cubrid/cubrid_utility.php +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -42,7 +42,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @access private * @return array */ - protected function _list_databases() + function _list_databases() { // CUBRID does not allow to see the list of all databases on the // server. It is the way its architecture is designed. Every @@ -71,7 +71,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Optimize%20Database */ - protected function _optimize_table($table) + function _optimize_table($table) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table optimization can be performed using CUBRID Manager @@ -91,7 +91,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @return object * @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency */ - protected function _repair_table($table) + function _repair_table($table) { // Not supported in CUBRID as of version 8.4.0. Database or // table consistency can be checked using CUBRID Manager @@ -107,7 +107,7 @@ class CI_DB_cubrid_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - protected function _backup($params = array()) + function _backup($params = array()) { // No SQL based support in CUBRID as of version 8.4.0. Database or // table backup can be performed using CUBRID Manager -- cgit v1.2.3-24-g4f1b From 175e289d092578952f134f7cad549bcc5e3efa17 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 19:08:39 -0400 Subject: Revert "Added access modifiers to CUBRID driver" This reverts commit 70b21018b4941414c0041900f26c637763e19cfe. --- system/database/drivers/cubrid/cubrid_driver.php | 87 +++++++++++++++--------- 1 file changed, 56 insertions(+), 31 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index cc9f23d9e..32bd8a8b2 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -66,9 +66,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Non-persistent database connection * + * @access private called by the base class * @return resource */ - protected function db_connect() + function db_connect() { // If no port is defined by the user, use the default value if ($this->port == '') @@ -105,12 +106,13 @@ class CI_DB_cubrid_driver extends CI_DB { * file by setting the CCI_PCONNECT parameter to ON. In that case, all * connections established between the client application and the * server will become persistent. This is calling the same - * @cubrid_connect public function will establish persisten connection + * @cubrid_connect function will establish persisten connection * considering that the CCI_PCONNECT is ON. * + * @access private called by the base class * @return resource */ - protected function db_pconnect() + function db_pconnect() { return $this->db_connect(); } @@ -123,9 +125,10 @@ class CI_DB_cubrid_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * + * @access public * @return void */ - public function reconnect() + function reconnect() { if (cubrid_ping($this->conn_id) === FALSE) { @@ -138,9 +141,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Select the database * + * @access private called by the base class * @return resource */ - public function db_select() + function db_select() { // In CUBRID there is no need to select a database as the database // is chosen at the connection time. @@ -168,10 +172,11 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Execute the query * + * @access private called by the base class * @param string an SQL query * @return resource */ - protected function _execute($sql) + function _execute($sql) { return @cubrid_query($sql, $this->conn_id); } @@ -181,9 +186,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Begin Transaction * + * @access public * @return bool */ - public function trans_begin($test_mode = FALSE) + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -214,9 +220,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Commit Transaction * + * @access public * @return bool */ - public function trans_commit() + function trans_commit() { if ( ! $this->trans_enabled) { @@ -244,9 +251,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Rollback Transaction * + * @access public * @return bool */ - public function trans_rollback() + function trans_rollback() { if ( ! $this->trans_enabled) { @@ -274,11 +282,12 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Escape String * + * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - public function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -315,7 +324,7 @@ class CI_DB_cubrid_driver extends CI_DB { * * @return int */ - public public function affected_rows() + public function affected_rows() { return @cubrid_affected_rows(); } @@ -325,9 +334,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Insert ID * + * @access public * @return integer */ - public function insert_id() + function insert_id() { return @cubrid_insert_id($this->conn_id); } @@ -340,10 +350,11 @@ class CI_DB_cubrid_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified table * + * @access public * @param string * @return string */ - public function count_all($table = '') + function count_all($table = '') { if ($table == '') { @@ -368,10 +379,11 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * + * @access private * @param boolean * @return string */ - protected function _list_tables($prefix_limit = FALSE) + function _list_tables($prefix_limit = FALSE) { $sql = "SHOW TABLES"; @@ -390,10 +402,11 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * + * @access public * @param string the table name * @return string */ - public function _list_columns($table = '') + function _list_columns($table = '') { return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); } @@ -405,10 +418,11 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * + * @access public * @param string the table name * @return object */ - public function _field_data($table) + function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -423,7 +437,7 @@ class CI_DB_cubrid_driver extends CI_DB { * * @return array */ - public public function error() + public function error() { return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id)); } @@ -431,12 +445,13 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Escape the SQL Identifiers * - * This public function escapes column and table names + * This function escapes column and table names * + * @access private * @param string * @return string */ - protected function _escape_identifiers($item) + function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -472,13 +487,14 @@ class CI_DB_cubrid_driver extends CI_DB { /** * From Tables * - * This public function implicitly groups FROM tables so there is no confusion + * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * + * @access public * @param type * @return type */ - public function _from_tables($tables) + function _from_tables($tables) { if ( ! is_array($tables)) { @@ -495,12 +511,13 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; } @@ -513,12 +530,13 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific replace string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _replace($table, $keys, $values) + function _replace($table, $keys, $values) { return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; } @@ -530,12 +548,13 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * + * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert_batch($table, $keys, $values) + function _insert_batch($table, $keys, $values) { return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values); } @@ -548,6 +567,7 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -555,7 +575,7 @@ class CI_DB_cubrid_driver extends CI_DB { * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -583,12 +603,13 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific batch update string from the supplied data * + * @access public * @param string the table name * @param array the update data * @param array the where clause * @return string */ - public function _update_batch($table, $values, $index, $where = NULL) + function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; @@ -635,12 +656,13 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This public function maps to "DELETE FROM table" + * This function maps to "DELETE FROM table" * + * @access public * @param string the table name * @return string */ - public function _truncate($table) + function _truncate($table) { return "TRUNCATE ".$table; } @@ -652,12 +674,13 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * + * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -685,12 +708,13 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * + * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -709,10 +733,11 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Close DB Connection * + * @access public * @param resource * @return void */ - public function _close($conn_id) + function _close($conn_id) { @cubrid_close($conn_id); } -- cgit v1.2.3-24-g4f1b From 738497c1dbfbc9558af0c5637e4715aefeb100da Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:12:25 +0200 Subject: Visibility declarations and cleanup for CI_DB_postgre_driver --- system/database/drivers/postgre/postgre_driver.php | 105 ++++++++------------- 1 file changed, 39 insertions(+), 66 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 5d22af2e6..1114e4cb2 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -1,13 +1,13 @@ - 'host', @@ -90,10 +87,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ - function db_connect() + public function db_connect() { return @pg_connect($this->_connect_string()); } @@ -103,10 +99,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { return @pg_pconnect($this->_connect_string()); } @@ -119,10 +114,9 @@ class CI_DB_postgre_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { if (pg_ping($this->conn_id) === FALSE) { @@ -135,10 +129,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { // Not needed for Postgre so we'll return TRUE return TRUE; @@ -191,11 +184,10 @@ class CI_DB_postgre_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { $sql = $this->_prep_query($sql); return @pg_query($this->conn_id, $sql); @@ -208,11 +200,10 @@ class CI_DB_postgre_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ - function _prep_query($sql) + protected function _prep_query($sql) { return $sql; } @@ -281,12 +272,11 @@ class CI_DB_postgre_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -316,10 +306,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ - function affected_rows() + public function affected_rows() { return @pg_affected_rows($this->result_id); } @@ -329,10 +318,9 @@ class CI_DB_postgre_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * @return string */ - function insert_id() + public function insert_id() { $v = $this->version(); @@ -372,11 +360,10 @@ class CI_DB_postgre_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -401,11 +388,10 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean + * @param bool * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; @@ -424,11 +410,10 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'"; } @@ -440,11 +425,10 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ - function _field_data($table) + protected function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -471,11 +455,10 @@ class CI_DB_postgre_driver extends CI_DB { * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -514,11 +497,10 @@ class CI_DB_postgre_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param array + * @return string */ - function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -535,13 +517,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -553,13 +534,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert_batch($table, $keys, $values) + protected function _insert_batch($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); } @@ -571,7 +551,6 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -579,7 +558,7 @@ class CI_DB_postgre_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -602,11 +581,10 @@ class CI_DB_postgre_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + protected function _truncate($table) { return "TRUNCATE ".$table; } @@ -618,13 +596,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -649,13 +626,12 @@ class CI_DB_postgre_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ - function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { $sql .= "LIMIT ".$limit; @@ -672,18 +648,15 @@ class CI_DB_postgre_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + protected function _close($conn_id) { @pg_close($conn_id); } - } - /* End of file postgre_driver.php */ /* Location: ./system/database/drivers/postgre/postgre_driver.php */ -- cgit v1.2.3-24-g4f1b From bde70bdd693bb0c56ad7a3b9144f88c1a84a4dfd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:15:12 +0200 Subject: Visibility declarations and cleanup for CI_DB_postgre_forge --- system/database/drivers/postgre/postgre_forge.php | 39 ++++++++++------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 577100544..2a8fdd676 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -1,13 +1,13 @@ -$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually @@ -168,7 +164,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { $sql .= ','; } } - + return $sql; } @@ -177,15 +173,14 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @param bool should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -241,8 +236,10 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Drop Table + * + * @return string */ - function _drop_table($table) + public function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE"; } @@ -255,7 +252,6 @@ class CI_DB_postgre_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -263,9 +259,9 @@ class CI_DB_postgre_forge extends CI_DB_forge { * @param string the default value * @param boolean should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $fields, $after_field = '') + public function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -292,12 +288,11 @@ class CI_DB_postgre_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } -- cgit v1.2.3-24-g4f1b From 02878c248f0fd83a890f9c75c54d9e39cd6be631 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:16:53 +0200 Subject: Visibility declarations and cleanup for CI_DB_postgre_result --- system/database/drivers/postgre/postgre_result.php | 42 +++++++++------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index 12d7547c5..b3eafb8f7 100644 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.php @@ -1,13 +1,13 @@ -result_id); } @@ -54,10 +51,9 @@ class CI_DB_postgre_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public - * @return integer + * @return int */ - function num_fields() + public function num_fields() { return @pg_num_fields($this->result_id); } @@ -69,10 +65,9 @@ class CI_DB_postgre_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -90,10 +85,9 @@ class CI_DB_postgre_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -116,9 +110,9 @@ class CI_DB_postgre_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ - function free_result() + public function free_result() { if (is_resource($this->result_id)) { @@ -132,14 +126,13 @@ class CI_DB_postgre_result extends CI_DB_result { /** * Data Seek * - * Moves the internal pointer to the desired offset. We call + * Moves the internal pointer to the desired offset. We call * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return pg_result_seek($this->result_id, $n); } @@ -151,10 +144,9 @@ class CI_DB_postgre_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return pg_fetch_assoc($this->result_id); } @@ -166,16 +158,14 @@ class CI_DB_postgre_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return pg_fetch_object($this->result_id); } } - /* End of file postgre_result.php */ -/* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file +/* Location: ./system/database/drivers/postgre/postgre_result.php */ -- cgit v1.2.3-24-g4f1b From 55201acd0692f02eb5927f412db73b925b6ba738 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:20:39 +0200 Subject: Fixed an issue with PostgreSQL's escape_str() --- system/database/drivers/postgre/postgre_driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 1114e4cb2..8112cf9de 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -293,9 +293,9 @@ class CI_DB_postgre_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), - $str); + return str_replace(array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), + $str); } return $str; -- cgit v1.2.3-24-g4f1b From 5f356bfa899ac953e987b4de67c954a779e8d3c9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:32:27 +0200 Subject: Visibility declarations and cleanup for CI_DB_odbc_driver --- system/database/drivers/odbc/odbc_driver.php | 108 ++++++++++----------------- 1 file changed, 40 insertions(+), 68 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index acc2838e3..b70713ce9 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -1,13 +1,13 @@ -hostname, $this->username, $this->password); } @@ -83,10 +80,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { return @odbc_pconnect($this->hostname, $this->username, $this->password); } @@ -99,10 +95,9 @@ class CI_DB_odbc_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in odbc } @@ -112,10 +107,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { // Not needed for ODBC return TRUE; @@ -126,11 +120,10 @@ class CI_DB_odbc_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { $sql = $this->_prep_query($sql); return @odbc_exec($this->conn_id, $sql); @@ -143,11 +136,10 @@ class CI_DB_odbc_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ - function _prep_query($sql) + protected function _prep_query($sql) { return $sql; } @@ -157,10 +149,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -186,10 +177,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -212,10 +202,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -238,12 +227,11 @@ class CI_DB_odbc_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -274,10 +262,9 @@ class CI_DB_odbc_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ - function affected_rows() + public function affected_rows() { return @odbc_num_rows($this->conn_id); } @@ -302,11 +289,10 @@ class CI_DB_odbc_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -332,11 +318,10 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean + * @param bool * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SHOW TABLES FROM `".$this->database."`"; @@ -356,11 +341,10 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { return "SHOW COLUMNS FROM ".$table; } @@ -372,11 +356,10 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name - * @return object + * @return string */ - function _field_data($table) + protected function _field_data($table) { return "SELECT TOP 1 FROM ".$table; } @@ -403,11 +386,10 @@ class CI_DB_odbc_driver extends CI_DB { * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -446,11 +428,10 @@ class CI_DB_odbc_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param array + * @return string */ - function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -467,13 +448,12 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -485,7 +465,6 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -493,7 +472,7 @@ class CI_DB_odbc_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -523,11 +502,10 @@ class CI_DB_odbc_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + protected function _truncate($table) { return $this->_delete($table); } @@ -539,13 +517,12 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -573,13 +550,12 @@ class CI_DB_odbc_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ - function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { // Does ODBC doesn't use the LIMIT clause? return $sql; @@ -590,19 +566,15 @@ class CI_DB_odbc_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + protected function _close($conn_id) { @odbc_close($conn_id); } - } - - /* End of file odbc_driver.php */ /* Location: ./system/database/drivers/odbc/odbc_driver.php */ -- cgit v1.2.3-24-g4f1b From f1bda680e08453e4c73177b9920b22fe362819eb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:35:06 +0200 Subject: Alter str_replace() order in ODBC's escape_str() --- system/database/drivers/odbc/odbc_driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index b70713ce9..5e3fd7aef 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -249,9 +249,9 @@ class CI_DB_odbc_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), - $str); + return str_replace(array($this->_like_escape_chr.$this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), + $str); } return $str; -- cgit v1.2.3-24-g4f1b From 9a8a11155a747bc7008f51393403eeb0dcc6aab0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:37:23 +0200 Subject: Visibility declarations and cleanup for CI_DB_odbc_forge --- system/database/drivers/odbc/odbc_forge.php | 34 +++++++++++------------------ 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index acc2cadee..26a524a64 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -1,13 +1,13 @@ -db->_escape_identifiers($table)." ("; $current_field_count = 0; - foreach ($fields as $field=>$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually @@ -186,10 +181,9 @@ class CI_DB_odbc_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return bool */ - function _drop_table($table) + public function _drop_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -207,17 +201,16 @@ class CI_DB_odbc_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name * @param string the column definition * @param string the default value - * @param boolean should 'NOT NULL' be added + * @param bool should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -260,12 +253,11 @@ class CI_DB_odbc_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } -- cgit v1.2.3-24-g4f1b From 2227fbaecf9dfea80958f23e8a1d359e2d6c5f72 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:40:14 +0200 Subject: Visibility declarations and cleanup for CI_DB_odbc_utility --- system/database/drivers/odbc/odbc_utility.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index c146c1785..5244f084f 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -1,13 +1,13 @@ -db->db_debug) @@ -59,11 +56,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * - * @access private * @param string the table name - * @return object + * @return bool */ - function _optimize_table($table) + public function _optimize_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -80,11 +76,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * - * @access private * @param string the table name - * @return object + * @return bool */ - function _repair_table($table) + public function _repair_table($table) { // Not a supported ODBC feature if ($this->db->db_debug) @@ -99,11 +94,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * ODBC Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); @@ -112,4 +106,4 @@ class CI_DB_odbc_utility extends CI_DB_utility { } /* End of file odbc_utility.php */ -/* Location: ./system/database/drivers/odbc/odbc_utility.php */ \ No newline at end of file +/* Location: ./system/database/drivers/odbc/odbc_utility.php */ -- cgit v1.2.3-24-g4f1b From 78ef5a58e180e288100639c08245c6d13d157455 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:43:34 +0200 Subject: Visibility declarations and cleanup for CI_DB_odbc_result --- system/database/drivers/odbc/odbc_result.php | 53 ++++++++++++++-------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index d19fa247e..f6aee356f 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -1,13 +1,13 @@ -result_id)) { @@ -148,10 +146,9 @@ class CI_DB_odbc_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private - * @return array + * @return bool */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return FALSE; } @@ -163,12 +160,11 @@ class CI_DB_odbc_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { - if (function_exists('odbc_fetch_object')) + if (function_exists('odbc_fetch_array')) { return odbc_fetch_array($this->result_id); } @@ -185,10 +181,9 @@ class CI_DB_odbc_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { if (function_exists('odbc_fetch_object')) { @@ -200,6 +195,7 @@ class CI_DB_odbc_result extends CI_DB_result { } } + // -------------------------------------------------------------------- /** * Result - object @@ -207,21 +203,24 @@ class CI_DB_odbc_result extends CI_DB_result { * subsititutes the odbc_fetch_object function when * not available (odbc_fetch_object requires unixODBC) * - * @access private * @return object */ - function _odbc_fetch_object(& $odbc_result) { + protected function _odbc_fetch_object(& $odbc_result) + { $rs = array(); $rs_obj = FALSE; - if (odbc_fetch_into($odbc_result, $rs)) { - foreach ($rs as $k=>$v) { - $field_name= odbc_field_name($odbc_result, $k+1); + if (odbc_fetch_into($odbc_result, $rs)) + { + foreach ($rs as $k => $v) + { + $field_name = odbc_field_name($odbc_result, $k+1); $rs_obj->$field_name = $v; } } return $rs_obj; } + // -------------------------------------------------------------------- /** * Result - array @@ -229,16 +228,18 @@ class CI_DB_odbc_result extends CI_DB_result { * subsititutes the odbc_fetch_array function when * not available (odbc_fetch_array requires unixODBC) * - * @access private * @return array */ - function _odbc_fetch_array(& $odbc_result) { + protected function _odbc_fetch_array(& $odbc_result) + { $rs = array(); $rs_assoc = FALSE; - if (odbc_fetch_into($odbc_result, $rs)) { - $rs_assoc=array(); - foreach ($rs as $k=>$v) { - $field_name= odbc_field_name($odbc_result, $k+1); + if (odbc_fetch_into($odbc_result, $rs)) + { + $rs_assoc = array(); + foreach ($rs as $k => $v) + { + $field_name = odbc_field_name($odbc_result, $k+1); $rs_assoc[$field_name] = $v; } } -- cgit v1.2.3-24-g4f1b From 6ea625e7f31b65838f1829408d37ac26009c79bc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 14:46:27 +0200 Subject: Again alter ODBC's escape_str() --- system/database/drivers/odbc/odbc_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 5e3fd7aef..cfa561c3d 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -249,7 +249,7 @@ class CI_DB_odbc_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - return str_replace(array($this->_like_escape_chr.$this->_like_escape_chr, '%', '_'), + return str_replace(array($this->_like_escape_chr, '%', '_'), array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), $str); } -- cgit v1.2.3-24-g4f1b From 592f4ec753a35e75d4c83d5ce19975f3e7287a08 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:10:08 +0200 Subject: Visibility declarations and cleanup for CI_DB_cubrid_driver --- system/database/drivers/cubrid/cubrid_driver.php | 124 +++++++++-------------- 1 file changed, 46 insertions(+), 78 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 244707395..7b468bc5c 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -1,13 +1,13 @@ -port == '') { - $this->port = self::DEFAULT_PORT; + // Default CUBRID Broker port + $this->port = 33000; } $conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password); @@ -101,6 +95,7 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Persistent database connection + * * In CUBRID persistent DB connection is supported natively in CUBRID * engine which can be configured in the CUBRID Broker configuration * file by setting the CCI_PCONNECT parameter to ON. In that case, all @@ -109,10 +104,9 @@ class CI_DB_cubrid_driver extends CI_DB { * @cubrid_connect function will establish persisten connection * considering that the CCI_PCONNECT is ON. * - * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { return $this->db_connect(); } @@ -125,10 +119,9 @@ class CI_DB_cubrid_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { if (cubrid_ping($this->conn_id) === FALSE) { @@ -141,10 +134,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { // In CUBRID there is no need to select a database as the database // is chosen at the connection time. @@ -172,11 +164,10 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { $sql = $this->_prep_query($sql); return @cubrid_query($sql, $this->conn_id); @@ -189,11 +180,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ - function _prep_query($sql) + protected function _prep_query($sql) { // No need to prepare return $sql; @@ -204,10 +194,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -238,10 +227,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -269,10 +257,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -300,12 +287,11 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -352,10 +338,9 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * @return int */ - function insert_id() + public function insert_id() { return @cubrid_insert_id($this->conn_id); } @@ -368,11 +353,10 @@ class CI_DB_cubrid_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified table * - * @access public * @param string - * @return string + * @return int */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -397,11 +381,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean + * @param bool * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SHOW TABLES"; @@ -420,11 +403,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); } @@ -436,11 +418,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name - * @return object + * @return string */ - function _field_data($table) + protected function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -465,11 +446,10 @@ class CI_DB_cubrid_driver extends CI_DB { * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -508,11 +488,10 @@ class CI_DB_cubrid_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param array + * @return string */ - function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -529,13 +508,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; } @@ -548,13 +526,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific replace string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _replace($table, $keys, $values) + protected function _replace($table, $keys, $values) { return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")"; } @@ -566,13 +543,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert_batch($table, $keys, $values) + protected function _insert_batch($table, $keys, $values) { return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values); } @@ -585,7 +561,6 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -593,7 +568,7 @@ class CI_DB_cubrid_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -621,13 +596,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific batch update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause * @return string */ - function _update_batch($table, $values, $index, $where = NULL) + protected function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; @@ -668,7 +642,6 @@ class CI_DB_cubrid_driver extends CI_DB { // -------------------------------------------------------------------- - /** * Truncate statement * @@ -676,11 +649,10 @@ class CI_DB_cubrid_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + protected function _truncate($table) { return "TRUNCATE ".$table; } @@ -692,13 +664,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -726,13 +697,12 @@ class CI_DB_cubrid_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ - function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -751,17 +721,15 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + protected function _close($conn_id) { @cubrid_close($conn_id); } } - /* End of file cubrid_driver.php */ /* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ -- cgit v1.2.3-24-g4f1b From 32ed1cc894726aefc333870a7183e0e944c61c0e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:11:50 +0200 Subject: Visibility declarations and cleanup for CI_DB_cubrid_result --- system/database/drivers/cubrid/cubrid_result.php | 38 +++++++++--------------- 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php index a7eeb8a39..6a61a213d 100644 --- a/system/database/drivers/cubrid/cubrid_result.php +++ b/system/database/drivers/cubrid/cubrid_result.php @@ -1,13 +1,13 @@ -result_id); } @@ -54,10 +51,9 @@ class CI_DB_cubrid_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public - * @return integer + * @return int */ - function num_fields() + public function num_fields() { return @cubrid_num_fields($this->result_id); } @@ -69,10 +65,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { return cubrid_column_names($this->result_id); } @@ -84,10 +79,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); @@ -147,9 +141,9 @@ class CI_DB_cubrid_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ - function free_result() + public function free_result() { if(is_resource($this->result_id) || get_resource_type($this->result_id) == "Unknown" && @@ -169,10 +163,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return cubrid_data_seek($this->result_id, $n); } @@ -184,10 +177,9 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return cubrid_fetch_assoc($this->result_id); } @@ -199,16 +191,14 @@ class CI_DB_cubrid_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return cubrid_fetch_object($this->result_id); } } - /* End of file cubrid_result.php */ /* Location: ./system/database/drivers/cubrid/cubrid_result.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 582d6a828221c8628faff91b62c5db981adbb1d8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:13:49 +0200 Subject: Visibility declarations and cleanup for CI_DB_cubrid_forge --- system/database/drivers/cubrid/cubrid_forge.php | 37 ++++++++++--------------- 1 file changed, 14 insertions(+), 23 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 7d606ea36..bbda484c4 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -1,13 +1,13 @@ -$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually @@ -172,15 +167,14 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param mixed the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @param bool should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -232,10 +226,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return string */ - function _drop_table($table) + public function _drop_table($table) { return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table); } @@ -248,14 +241,13 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param array fields * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $fields, $after_field = '') + public function _alter_table($alter_type, $table, $fields, $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; @@ -282,12 +274,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name); } @@ -295,4 +286,4 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } /* End of file cubrid_forge.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From e3e3d50576608e0aa0428358b2fae2da29759901 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:14:45 +0200 Subject: Visibility declarations and cleanup for CI_DB_cubrid_utility --- system/database/drivers/cubrid/cubrid_utility.php | 24 +++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php index a13c0a5e4..dafd66146 100644 --- a/system/database/drivers/cubrid/cubrid_utility.php +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -1,13 +1,13 @@ - Date: Tue, 20 Mar 2012 15:15:57 +0200 Subject: Switch _process_fields() method in MySQL/MySQLi to protected --- system/database/drivers/mysql/mysql_forge.php | 2 +- system/database/drivers/mysqli/mysqli_forge.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 004a5a103..d317ac3e0 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -66,7 +66,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - private function _process_fields($fields) + protected function _process_fields($fields) { $current_field_count = 0; $sql = ''; diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 9cb1a0c70..9ec4bf7aa 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -66,7 +66,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - public function _process_fields($fields) + protected function _process_fields($fields) { $current_field_count = 0; $sql = ''; -- cgit v1.2.3-24-g4f1b From 65b568fcd444fbeaf6fa9130289c254e34e5bbbd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:33:15 +0200 Subject: Remove EOF newlines --- system/database/DB.php | 2 +- system/database/DB_driver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB.php b/system/database/DB.php index 8f9cb3743..e9d70ccc2 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -161,4 +161,4 @@ function &DB($params = '', $active_record_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 73f3e44d7..7fc569e9a 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1327,4 +1327,4 @@ class CI_DB_driver { } /* End of file DB_driver.php */ -/* Location: ./system/database/DB_driver.php */ +/* Location: ./system/database/DB_driver.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 35bbb1ab4f7ee09d75fb407c6d9d9637b4404698 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:33:55 +0200 Subject: Remove EOF newlines --- system/database/DB.php | 2 +- system/database/DB_driver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB.php b/system/database/DB.php index be6ee9c2f..7c12e562b 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -161,4 +161,4 @@ function &DB($params = '', $active_record_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 162d3bbb2..1fce76cb5 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1327,4 +1327,4 @@ class CI_DB_driver { } /* End of file DB_driver.php */ -/* Location: ./system/database/DB_driver.php */ +/* Location: ./system/database/DB_driver.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0336dc228c84695ec75fc8dccedac354d1556de9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:34:28 +0200 Subject: Remove EOF newline --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index aa838eeca..c9810fab9 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -412,4 +412,4 @@ class CI_Zip { } /* End of file Zip.php */ -/* Location: ./system/libraries/Zip.php */ +/* Location: ./system/libraries/Zip.php */ \ No newline at end of file -- 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_active_rec.php | 22 +++++++++++----------- system/database/DB_cache.php | 2 +- system/database/DB_forge.php | 2 +- system/database/DB_result.php | 2 +- system/database/DB_utility.php | 2 +- system/database/drivers/cubrid/cubrid_driver.php | 2 +- .../drivers/interbase/interbase_driver.php | 2 +- system/database/drivers/mssql/mssql_driver.php | 4 +--- system/database/drivers/mssql/mssql_forge.php | 2 +- system/database/drivers/mssql/mssql_result.php | 1 - system/database/drivers/mysql/mysql_forge.php | 2 +- system/database/drivers/mysqli/mysqli_forge.php | 2 +- system/database/drivers/oci8/oci8_driver.php | 4 +--- system/database/drivers/oci8/oci8_forge.php | 2 +- system/database/drivers/oci8/oci8_result.php | 3 +-- system/database/drivers/odbc/odbc_driver.php | 2 +- system/database/drivers/odbc/odbc_forge.php | 2 +- system/database/drivers/odbc/odbc_result.php | 2 +- system/database/drivers/odbc/odbc_utility.php | 2 +- system/database/drivers/pdo/pdo_driver.php | 2 +- system/database/drivers/pdo/pdo_forge.php | 2 +- system/database/drivers/postgre/postgre_forge.php | 2 +- system/database/drivers/postgre/postgre_result.php | 2 +- .../database/drivers/postgre/postgre_utility.php | 2 +- system/database/drivers/sqlite/sqlite_driver.php | 2 +- system/database/drivers/sqlite/sqlite_forge.php | 2 +- system/database/drivers/sqlite/sqlite_utility.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_driver.php | 4 +--- system/database/drivers/sqlsrv/sqlsrv_forge.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_result.php | 1 - 30 files changed, 38 insertions(+), 47 deletions(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 89369f190..fe591dda1 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -2197,19 +2197,19 @@ abstract class CI_DB_active_record extends CI_DB_driver { protected function _reset_write() { $this->_reset_run(array( - 'ar_set' => array(), - 'ar_from' => array(), - 'ar_where' => array(), - 'ar_like' => array(), - 'ar_orderby' => array(), - 'ar_keys' => array(), - 'ar_limit' => FALSE, - 'ar_order' => FALSE - ) - ); + 'ar_set' => array(), + 'ar_from' => array(), + 'ar_where' => array(), + 'ar_like' => array(), + 'ar_orderby' => array(), + 'ar_keys' => array(), + 'ar_limit' => FALSE, + 'ar_order' => FALSE + ) + ); } } /* End of file DB_active_rec.php */ -/* Location: ./system/database/DB_active_rec.php */ +/* Location: ./system/database/DB_active_rec.php */ \ No newline at end of file diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index fb0cfa89a..58e6968c0 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -183,4 +183,4 @@ class CI_DB_Cache { } /* End of file DB_cache.php */ -/* Location: ./system/database/DB_cache.php */ +/* Location: ./system/database/DB_cache.php */ \ No newline at end of file diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 192b78fa6..34c502a99 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -346,4 +346,4 @@ abstract class CI_DB_forge { } /* End of file DB_forge.php */ -/* Location: ./system/database/DB_forge.php */ +/* Location: ./system/database/DB_forge.php */ \ No newline at end of file diff --git a/system/database/DB_result.php b/system/database/DB_result.php index d0205e0fd..37c50e577 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -392,4 +392,4 @@ abstract class CI_DB_result { } /* End of file DB_result.php */ -/* Location: ./system/database/DB_result.php */ +/* Location: ./system/database/DB_result.php */ \ No newline at end of file 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 diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index f6b08daa0..f39c2ad76 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -715,4 +715,4 @@ class CI_DB_cubrid_driver extends CI_DB { } /* End of file cubrid_driver.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 4af5b57ed..9fa03adc7 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -607,4 +607,4 @@ SQL; } /* End of file interbase_driver.php */ -/* Location: ./system/database/drivers/interbase/interbase_driver.php */ +/* Location: ./system/database/drivers/interbase/interbase_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index a93ac57fe..ccbc3c456 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -639,7 +639,5 @@ class CI_DB_mssql_driver extends CI_DB { } - - /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index 4a8089bb1..ee8b8f544 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -256,4 +256,4 @@ class CI_DB_mssql_forge extends CI_DB_forge { } /* End of file mssql_forge.php */ -/* Location: ./system/database/drivers/mssql/mssql_forge.php */ +/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index b205ce2d1..c77c5a752 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -176,6 +176,5 @@ class CI_DB_mssql_result extends CI_DB_result { } - /* End of file mssql_result.php */ /* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index d317ac3e0..11172b41b 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -237,4 +237,4 @@ class CI_DB_mysql_forge extends CI_DB_forge { } /* End of file mysql_forge.php */ -/* Location: ./system/database/drivers/mysql/mysql_forge.php */ +/* Location: ./system/database/drivers/mysql/mysql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 9ec4bf7aa..8cf0ae1fd 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -237,4 +237,4 @@ class CI_DB_mysqli_forge extends CI_DB_forge { } /* End of file mysqli_forge.php */ -/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 8d7040618..e3846bc1a 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -781,7 +781,5 @@ class CI_DB_oci8_driver extends CI_DB { } - - /* End of file oci8_driver.php */ -/* Location: ./system/database/drivers/oci8/oci8_driver.php */ +/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 7fcc8094d..0a251998b 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -225,4 +225,4 @@ class CI_DB_oci8_forge extends CI_DB_forge { } /* End of file oci8_forge.php */ -/* Location: ./system/database/drivers/oci8/oci8_forge.php */ +/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 6f1b8b4c1..a14e32eec 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -235,6 +235,5 @@ class CI_DB_oci8_result extends CI_DB_result { } - /* End of file oci8_result.php */ -/* Location: ./system/database/drivers/oci8/oci8_result.php */ +/* Location: ./system/database/drivers/oci8/oci8_result.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 87abedec9..6704264c6 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -561,4 +561,4 @@ class CI_DB_odbc_driver extends CI_DB { } /* End of file odbc_driver.php */ -/* Location: ./system/database/drivers/odbc/odbc_driver.php */ +/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index 26a524a64..486a8dd7f 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -265,4 +265,4 @@ class CI_DB_odbc_forge extends CI_DB_forge { } /* End of file odbc_forge.php */ -/* Location: ./system/database/drivers/odbc/odbc_forge.php */ +/* Location: ./system/database/drivers/odbc/odbc_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index f6aee356f..30cc979ce 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -319,4 +319,4 @@ class CI_DB_odbc_result extends CI_DB_result { } /* End of file odbc_result.php */ -/* Location: ./system/database/drivers/odbc/odbc_result.php */ +/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index 5244f084f..65445e96c 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -106,4 +106,4 @@ class CI_DB_odbc_utility extends CI_DB_utility { } /* End of file odbc_utility.php */ -/* Location: ./system/database/drivers/odbc/odbc_utility.php */ +/* Location: ./system/database/drivers/odbc/odbc_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 658a3d5a0..9b44e7c64 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -942,4 +942,4 @@ class CI_DB_pdo_driver extends CI_DB { } /* End of file pdo_driver.php */ -/* Location: ./system/database/drivers/pdo/pdo_driver.php */ +/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 87b638570..2e5c81de3 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -278,4 +278,4 @@ class CI_DB_pdo_forge extends CI_DB_forge { } /* End of file pdo_forge.php */ -/* Location: ./system/database/drivers/pdo/pdo_forge.php */ +/* Location: ./system/database/drivers/pdo/pdo_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 2a8fdd676..a72449820 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -299,4 +299,4 @@ class CI_DB_postgre_forge extends CI_DB_forge { } /* End of file postgre_forge.php */ -/* Location: ./system/database/drivers/postgre/postgre_forge.php */ +/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index b3eafb8f7..8b22564b3 100644 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.php @@ -168,4 +168,4 @@ class CI_DB_postgre_result extends CI_DB_result { } /* End of file postgre_result.php */ -/* Location: ./system/database/drivers/postgre/postgre_result.php */ +/* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index e31a6db8f..c6b71b4d9 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -86,4 +86,4 @@ class CI_DB_postgre_utility extends CI_DB_utility { } /* End of file postgre_utility.php */ -/* Location: ./system/database/drivers/postgre/postgre_utility.php */ +/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 1870e73b7..de72b5454 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -623,4 +623,4 @@ class CI_DB_sqlite_driver extends CI_DB { /* End of file sqlite_driver.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 7fc531463..26d0d94bf 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -274,4 +274,4 @@ class CI_DB_sqlite_forge extends CI_DB_forge { } /* End of file sqlite_forge.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index 9f9ddca44..c07004c54 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -94,4 +94,4 @@ class CI_DB_sqlite_utility extends CI_DB_utility { } /* End of file sqlite_utility.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index ea9f9483b..0239e8f56 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -601,7 +601,5 @@ class CI_DB_sqlsrv_driver extends CI_DB { } - - /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index cd061dd23..0a276e172 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -256,4 +256,4 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { } /* End of file sqlsrv_forge.php */ -/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php index 52d338a30..d980f98ff 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_result.php +++ b/system/database/drivers/sqlsrv/sqlsrv_result.php @@ -176,6 +176,5 @@ class CI_DB_sqlsrv_result extends CI_DB_result { } - /* End of file mssql_result.php */ /* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From e6f7d610b189e243ad48dcc3900a5c53cab2498d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:39:22 +0200 Subject: Remove EOF newlines --- system/helpers/array_helper.php | 2 +- system/helpers/captcha_helper.php | 2 +- system/helpers/cookie_helper.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 464d1d112..6f56d9db9 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -103,4 +103,4 @@ if ( ! function_exists('elements')) } /* End of file array_helper.php */ -/* Location: ./system/helpers/array_helper.php */ +/* Location: ./system/helpers/array_helper.php */ \ No newline at end of file diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 7dc5b3eec..96e8c51a3 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -204,4 +204,4 @@ if ( ! function_exists('create_captcha')) } /* End of file captcha_helper.php */ -/* Location: ./system/helpers/captcha_helper.php */ +/* Location: ./system/helpers/captcha_helper.php */ \ No newline at end of file diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index ec8aa3250..06560e723 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -102,4 +102,4 @@ if ( ! function_exists('delete_cookie')) } /* End of file cookie_helper.php */ -/* Location: ./system/helpers/cookie_helper.php */ +/* Location: ./system/helpers/cookie_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6dd4aff404c675d8da6ddfbd905bf4dbc13dece7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:54:23 +0200 Subject: Revert CI_DB_result to a regular class It's directly instantiated for cached database results --- system/database/DB_result.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 37c50e577..04f964fb1 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -36,7 +36,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -abstract class CI_DB_result { +class CI_DB_result { public $conn_id = NULL; public $result_id = NULL; -- cgit v1.2.3-24-g4f1b From 1f619a889efbe71e66553de7918965f062c3c828 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:03:04 +0200 Subject: Visibility declarations and cleanup for CI_DB_mssql_driver --- system/database/drivers/mssql/mssql_driver.php | 136 ++++++++++--------------- 1 file changed, 56 insertions(+), 80 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index ccbc3c456..1c1b84582 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -1,13 +1,13 @@ -port != '') { @@ -80,10 +77,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { if ($this->port != '') { @@ -101,10 +97,9 @@ class CI_DB_mssql_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in MSSQL } @@ -140,11 +135,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return @mssql_query($sql, $this->conn_id); } @@ -154,10 +148,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -184,10 +177,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -209,10 +201,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -234,12 +225,11 @@ class CI_DB_mssql_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -272,10 +262,9 @@ class CI_DB_mssql_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ - function affected_rows() + public function affected_rows() { return @mssql_rows_affected($this->conn_id); } @@ -283,14 +272,13 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Insert ID - * - * Returns the last id created in the Identity column. - * - * @access public - * @return integer - */ - function insert_id() + * Insert ID + * + * Returns the last id created in the Identity column. + * + * @return string + */ + public function insert_id() { $ver = self::_parse_major_version($this->version()); $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id"); @@ -302,16 +290,15 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Parse major version - * - * Grabs the major version number from the - * database server version string passed in. - * - * @access private - * @param string $version - * @return int16 major version number - */ - function _parse_major_version($version) + * Parse major version + * + * Grabs the major version number from the + * database server version string passed in. + * + * @param string $version + * @return int major version number + */ + protected function _parse_major_version($version) { preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); return $ver_info[1]; // return the major version b/c that's all we're interested in. @@ -320,10 +307,10 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string - * - * @return string - */ + * Version number query string + * + * @return string + */ protected function _version() { return 'SELECT @@VERSION AS ver'; @@ -337,11 +324,10 @@ class CI_DB_mssql_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -366,11 +352,10 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean + * @param bool * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; @@ -391,11 +376,10 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access private * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'"; } @@ -407,11 +391,10 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name - * @return object + * @return string */ - function _field_data($table) + protected function _field_data($table) { return "SELECT TOP 1 * FROM ".$table; } @@ -440,11 +423,10 @@ class CI_DB_mssql_driver extends CI_DB { * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -483,11 +465,10 @@ class CI_DB_mssql_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param array + * @return string */ - function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -504,13 +485,12 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -522,7 +502,6 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -530,7 +509,7 @@ class CI_DB_mssql_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -560,11 +539,10 @@ class CI_DB_mssql_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + protected function _truncate($table) { return "TRUNCATE ".$table; } @@ -610,13 +588,12 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ - function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { $i = $limit + $offset; @@ -628,11 +605,10 @@ class CI_DB_mssql_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + protected function _close($conn_id) { @mssql_close($conn_id); } -- cgit v1.2.3-24-g4f1b From 11559020f790fe7be8018aa42663e9d5976f012a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:04:48 +0200 Subject: Visibility declarations and cleanup for CI_DB_mssql_result --- system/database/drivers/mssql/mssql_result.php | 37 ++++++++++---------------- 1 file changed, 14 insertions(+), 23 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index c77c5a752..2723f4614 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -1,13 +1,13 @@ -result_id); } @@ -54,10 +51,9 @@ class CI_DB_mssql_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public - * @return integer + * @return int */ - function num_fields() + public function num_fields() { return @mssql_num_fields($this->result_id); } @@ -69,10 +65,9 @@ class CI_DB_mssql_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); while ($field = mssql_fetch_field($this->result_id)) @@ -90,10 +85,9 @@ class CI_DB_mssql_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); while ($field = mssql_fetch_field($this->result_id)) @@ -116,9 +110,9 @@ class CI_DB_mssql_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ - function free_result() + public function free_result() { if (is_resource($this->result_id)) { @@ -136,10 +130,9 @@ class CI_DB_mssql_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return mssql_data_seek($this->result_id, $n); } @@ -151,10 +144,9 @@ class CI_DB_mssql_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return mssql_fetch_assoc($this->result_id); } @@ -166,10 +158,9 @@ class CI_DB_mssql_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return mssql_fetch_object($this->result_id); } -- cgit v1.2.3-24-g4f1b From c066481ed558e764ab489449141d2489551b562f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:07:59 +0200 Subject: Visibility declarations and cleanup for MSSQL forge and utility classes --- system/database/drivers/mssql/mssql_forge.php | 43 +++++++++++-------------- system/database/drivers/mssql/mssql_utility.php | 26 ++++++--------- 2 files changed, 28 insertions(+), 41 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index ee8b8f544..2e3e314ed 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -1,13 +1,13 @@ -db->_escape_identifiers($table); } @@ -80,15 +76,14 @@ class CI_DB_mssql_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL - * @return bool + * @param bool should 'IF NOT EXISTS' be added to the SQL + * @return string */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -100,7 +95,7 @@ class CI_DB_mssql_forge extends CI_DB_forge { $sql .= $this->db->_escape_identifiers($table)." ("; $current_field_count = 0; - foreach ($fields as $field=>$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually @@ -190,17 +185,16 @@ class CI_DB_mssql_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name * @param string the column definition * @param string the default value - * @param boolean should 'NOT NULL' be added + * @param bool should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -242,12 +236,11 @@ class CI_DB_mssql_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index 28f34b999..5c144330d 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -1,13 +1,13 @@ -db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From e62973498626a163427f2d2346f21d6d0506a288 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:25:07 +0200 Subject: Visibility declarations and cleanup for CI_DB_sqlsrv_driver --- system/database/drivers/sqlsrv/sqlsrv_driver.php | 206 ++++++++++------------- 1 file changed, 85 insertions(+), 121 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 0239e8f56..2b9f82201 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -1,13 +1,13 @@ -char_set)) ? 'UTF-8' : $this->char_set; @@ -78,10 +75,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { 'CharacterSet' => $character_set, 'ReturnDatesAsStrings' => 1 ); - - // If the username and password are both empty, assume this is a + + // If the username and password are both empty, assume this is a // 'Windows Authentication Mode' connection. - if(empty($connection['UID']) && empty($connection['PWD'])) { + if (empty($connection['UID']) && empty($connection['PWD'])) + { unset($connection['UID'], $connection['PWD']); } @@ -93,10 +91,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { return $this->db_connect(TRUE); } @@ -109,10 +106,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in MSSQL } @@ -146,16 +142,16 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { - return sqlsrv_query($this->conn_id, $sql, null, array( - 'Scrollable' => SQLSRV_CURSOR_STATIC, - 'SendStreamParamsAtExec' => true - )); + return sqlsrv_query($this->conn_id, + $sql, + NULL, + array('Scrollable'=> SQLSRV_CURSOR_STATIC, 'SendStreamParamsAtExec' => TRUE) + ); } // -------------------------------------------------------------------- @@ -163,10 +159,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -192,10 +187,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -216,10 +210,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -240,12 +233,11 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { // Escape single quotes return str_replace("'", "''", $str); @@ -256,10 +248,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ - function affected_rows() + public function affected_rows() { return @sqlrv_rows_affected($this->conn_id); } @@ -267,31 +258,31 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Insert ID - * - * Returns the last id created in the Identity column. - * - * @access public - * @return integer - */ - function insert_id() + * Insert ID + * + * Returns the last id created in the Identity column. + * + * @return string + */ + public function insert_id() { - return $this->query('select @@IDENTITY as insert_id')->row('insert_id'); + $query = $this->query('SELECT @@IDENTITY AS insert_id'); + $query = $query->row(); + return $query->insert_id; } // -------------------------------------------------------------------- /** - * Parse major version - * - * Grabs the major version number from the - * database server version string passed in. - * - * @access private - * @param string $version - * @return int16 major version number - */ - function _parse_major_version($version) + * Parse major version + * + * Grabs the major version number from the + * database server version string passed in. + * + * @param string $version + * @return int major version number + */ + protected function _parse_major_version($version) { preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); return $ver_info[1]; // return the major version b/c that's all we're interested in. @@ -327,23 +318,25 @@ class CI_DB_sqlsrv_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string - * @return string + * @return int */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') - return '0'; - + { + return 0; + } + $query = $this->query("SELECT COUNT(*) AS numrows FROM " . $this->dbprefix . $table); - if ($query->num_rows() == 0) - return '0'; + { + return 0; + } $row = $query->row(); $this->_reset_select(); - return $row->numrows; + return (int) $row->numrows; } // -------------------------------------------------------------------- @@ -353,11 +346,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean + * @param bool * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; } @@ -369,13 +361,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access private * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { - return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'"; + return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'"; } // -------------------------------------------------------------------- @@ -385,13 +376,12 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name - * @return object + * @return string */ - function _field_data($table) + protected function _field_data($table) { - return "SELECT TOP 1 * FROM " . $this->_escape_table($table); + return 'SELECT TOP 1 * FROM '.$table; } // -------------------------------------------------------------------- @@ -434,32 +424,15 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Escape Table Name - * - * This function adds backticks if the table name has a period - * in it. Some DBs will get cranky unless periods are escaped - * - * @access private - * @param string the table name - * @return string - */ - function _escape_table($table) - { - return $table; - } - - /** * Escape the SQL Identifiers * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { return $item; } @@ -472,11 +445,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param array + * @return string */ - function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -493,15 +465,14 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) - { - return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + protected function _insert($table, $keys, $values) + { + return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } // -------------------------------------------------------------------- @@ -511,7 +482,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -519,16 +489,16 @@ class CI_DB_sqlsrv_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where) + protected function _update($table, $values, $where) { foreach($values as $key => $val) { $valstr[] = $key." = ".$val; } - - return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where); + + return 'UPDATE '.$table.' SET '.implode(', ', $valstr).' WHERE '.implode(' ', $where); } - + // -------------------------------------------------------------------- /** @@ -538,11 +508,10 @@ class CI_DB_sqlsrv_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + protected function _truncate($table) { return "TRUNCATE ".$table; } @@ -554,15 +523,14 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where) + protected function _delete($table, $where) { - return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where); + return 'DELETE FROM '.$table.' WHERE '.implode(' ', $where); } // -------------------------------------------------------------------- @@ -572,17 +540,14 @@ class CI_DB_sqlsrv_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ - function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { - $i = $limit + $offset; - - return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql); + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql); } // -------------------------------------------------------------------- @@ -590,16 +555,15 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + protected function _close($conn_id) { @sqlsrv_close($conn_id); } } -/* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file +/* End of file sqlsrv_driver.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 9659bd5bca64832598be7f8c9528c401ca139ea8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:27:47 +0200 Subject: Visibility declarations and cleanup for CI_DB_sqlsrv_result --- system/database/drivers/sqlsrv/sqlsrv_result.php | 55 ++++++++++-------------- 1 file changed, 23 insertions(+), 32 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php index d980f98ff..10d790e4b 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_result.php +++ b/system/database/drivers/sqlsrv/sqlsrv_result.php @@ -1,13 +1,13 @@ -result_id); } @@ -54,10 +51,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public - * @return integer + * @return int */ - function num_fields() + public function num_fields() { return @sqlsrv_num_fields($this->result_id); } @@ -69,17 +65,16 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); - foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field) + foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field) { $field_names[] = $field['Name']; } - + return $field_names; } @@ -90,13 +85,12 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); - foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field) + foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field) { $F = new stdClass(); $F->name = $field['Name']; @@ -104,10 +98,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result { $F->max_length = $field['Size']; $F->primary_key = 0; $F->default = ''; - + $retval[] = $F; } - + return $retval; } @@ -116,9 +110,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ - function free_result() + public function free_result() { if (is_resource($this->result_id)) { @@ -132,14 +126,13 @@ class CI_DB_sqlsrv_result extends CI_DB_result { /** * Data Seek * - * Moves the internal pointer to the desired offset. We call + * Moves the internal pointer to the desired offset. We call * this internally before fetching results to make sure the * result set starts at zero * - * @access private - * @return array + * @return void */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { // Not implemented } @@ -151,10 +144,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC); } @@ -166,15 +158,14 @@ class CI_DB_sqlsrv_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { return sqlsrv_fetch_object($this->result_id); } } -/* End of file mssql_result.php */ -/* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file +/* End of file sqlsrv_result.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_result.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4d1167149a9bad94bdc6a6947525d4c610f0e3aa Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:30:57 +0200 Subject: Visibility declarations and cleanup for SQLSRV forge and utility classes --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 36 +++++++++-------------- system/database/drivers/sqlsrv/sqlsrv_utility.php | 30 ++++++++----------- 2 files changed, 26 insertions(+), 40 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 0a276e172..0dc7b5242 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -1,13 +1,13 @@ -db->_escape_identifiers($table); } @@ -80,15 +75,14 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @param bool should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -100,7 +94,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { $sql .= $this->db->_escape_identifiers($table)." ("; $current_field_count = 0; - foreach ($fields as $field=>$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually @@ -190,17 +184,16 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name * @param string the column definition * @param string the default value - * @param boolean should 'NOT NULL' be added + * @param bool should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -242,12 +235,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { // I think this syntax will work, but can find little documentation on renaming tables in MSSQL return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index 44e6fafeb..5830c62de 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php @@ -1,13 +1,13 @@ -db->display_error('db_unsuported_feature'); @@ -96,5 +90,5 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility { } -/* End of file mssql_utility.php */ -/* Location: ./system/database/drivers/mssql/mssql_utility.php */ \ No newline at end of file +/* End of file sqlsrv_utility.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 979b5280f98a962dd83a5b8923edd4eef224ce74 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:45:39 +0200 Subject: Visibility declarations and cleanup for CI_DB_sqlite_driver --- system/database/drivers/sqlite/sqlite_driver.php | 109 +++++++++-------------- 1 file changed, 41 insertions(+), 68 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index de72b5454..bb86c2296 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -1,13 +1,13 @@ -database, FILE_WRITE_MODE, $error)) { @@ -87,10 +84,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error)) { @@ -115,10 +111,9 @@ class CI_DB_sqlite_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in SQLite } @@ -128,10 +123,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { return TRUE; } @@ -155,11 +149,10 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + protected function _execute($sql) { return @sqlite_query($this->conn_id, $sql); } @@ -169,10 +162,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -199,10 +191,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -224,10 +215,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -249,12 +239,11 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -284,10 +273,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ - function affected_rows() + public function affected_rows() { return sqlite_changes($this->conn_id); } @@ -297,10 +285,9 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * @return int */ - function insert_id() + public function insert_id() { return @sqlite_last_insert_rowid($this->conn_id); } @@ -313,11 +300,10 @@ class CI_DB_sqlite_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -342,11 +328,10 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean + * @param bool * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT name from sqlite_master WHERE type='table'"; @@ -364,11 +349,10 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name - * @return string + * @return bool */ - function _list_columns($table = '') + protected function _list_columns($table = '') { // Not supported return FALSE; @@ -381,11 +365,10 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name - * @return object + * @return string */ - function _field_data($table) + protected function _field_data($table) { return "SELECT * FROM ".$table." LIMIT 1"; } @@ -414,11 +397,10 @@ class CI_DB_sqlite_driver extends CI_DB { * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -457,11 +439,10 @@ class CI_DB_sqlite_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param array + * @return string */ - function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -478,13 +459,12 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -496,7 +476,6 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -504,7 +483,7 @@ class CI_DB_sqlite_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -534,11 +513,10 @@ class CI_DB_sqlite_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + protected function _truncate($table) { return $this->_delete($table); } @@ -550,13 +528,12 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -584,13 +561,12 @@ class CI_DB_sqlite_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ - function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -609,18 +585,15 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + protected function _close($conn_id) { @sqlite_close($conn_id); } - } - /* End of file sqlite_driver.php */ /* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From f4ebb0e3e81b64e0287ce1627960850adb013f6f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:52:56 +0200 Subject: Visibility declarations and cleanup for CI_DB_sqlite_result --- system/database/drivers/sqlite/sqlite_result.php | 40 +++++++++--------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php index ac2235cbc..b002aeff1 100644 --- a/system/database/drivers/sqlite/sqlite_result.php +++ b/system/database/drivers/sqlite/sqlite_result.php @@ -1,13 +1,13 @@ -result_id); } @@ -54,10 +51,9 @@ class CI_DB_sqlite_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public - * @return integer + * @return int */ - function num_fields() + public function num_fields() { return @sqlite_num_fields($this->result_id); } @@ -69,10 +65,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -90,10 +85,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -116,9 +110,9 @@ class CI_DB_sqlite_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ - function free_result() + public function free_result() { // Not implemented in SQLite } @@ -128,14 +122,13 @@ class CI_DB_sqlite_result extends CI_DB_result { /** * Data Seek * - * Moves the internal pointer to the desired offset. We call + * Moves the internal pointer to the desired offset. We call * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return sqlite_seek($this->result_id, $n); } @@ -147,10 +140,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return sqlite_fetch_array($this->result_id); } @@ -162,10 +154,9 @@ class CI_DB_sqlite_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() + protected function _fetch_object() { if (function_exists('sqlite_fetch_object')) { @@ -186,6 +177,5 @@ class CI_DB_sqlite_result extends CI_DB_result { } - /* End of file sqlite_result.php */ /* Location: ./system/database/drivers/sqlite/sqlite_result.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 8480f7c35af9aacaf2ebee43677ff1d31a5cce13 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 16:55:05 +0200 Subject: Visibility declarations and cleanup for CI_DB_sqlite_forge --- system/database/drivers/sqlite/sqlite_forge.php | 35 +++++++++---------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 26d0d94bf..068a556ed 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -1,13 +1,13 @@ -db->database) OR ! @unlink($this->db->database)) { @@ -71,20 +67,20 @@ class CI_DB_sqlite_forge extends CI_DB_forge { } return TRUE; } + // -------------------------------------------------------------------- /** * Create Table * - * @access private * @param string the table name * @param array the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @param bool should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -184,12 +180,9 @@ class CI_DB_sqlite_forge extends CI_DB_forge { /** * Drop Table * - * Unsupported feature in SQLite - * - * @access private * @return bool */ - function _drop_table($table) + public function _drop_table($table) { if ($this->db->db_debug) { @@ -206,17 +199,16 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name * @param string the column definition * @param string the default value - * @param boolean should 'NOT NULL' be added + * @param bool should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -261,12 +253,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } -- cgit v1.2.3-24-g4f1b From f944d3b50ad589aeb78fe04ceef9ebfe4c3bd692 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 22:12:55 +0200 Subject: Remove unused _prep_query() method --- system/database/drivers/sqlite3/sqlite3_driver.php | 17 +---------------- system/database/drivers/sqlite3/sqlite3_forge.php | 2 +- system/database/drivers/sqlite3/sqlite3_result.php | 4 ++-- system/database/drivers/sqlite3/sqlite3_utility.php | 3 ++- 4 files changed, 6 insertions(+), 20 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index ed081102b..a3f5191b4 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -154,21 +154,6 @@ class CI_DB_sqlite3_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Prep the query - * - * If needed, each database adapter can prep the query string - * - * @param string an SQL query - * @return string - */ - protected function _prep_query($sql) - { - return $sql; - } - - // -------------------------------------------------------------------- - /** * Begin Transaction * @@ -561,4 +546,4 @@ class CI_DB_sqlite3_driver extends CI_DB { } /* End of file sqlite3_driver.php */ -/* Location: ./system/database/drivers/sqlite3/sqlite3_driver.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index 68da7627e..254db21d8 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -220,4 +220,4 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { } /* End of file sqlite3_forge.php */ -/* Location: ./system/database/drivers/sqlite3/sqlite3_forge.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php index c88696328..ddf59dbd0 100644 --- a/system/database/drivers/sqlite3/sqlite3_result.php +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -607,7 +607,7 @@ class CI_DB_sqlite3_result extends CI_DB_result { * * @return array */ - public function _data_seek($n = 0) + protected function _data_seek($n = 0) { // Only resetting to the start of the result set is supported return $this->result_id->reset(); @@ -616,4 +616,4 @@ class CI_DB_sqlite3_result extends CI_DB_result { } /* End of file sqlite3_result.php */ -/* Location: ./system/database/drivers/sqlite3/sqlite3_result.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_utility.php b/system/database/drivers/sqlite3/sqlite3_utility.php index bc9898ee4..a4dc875e1 100644 --- a/system/database/drivers/sqlite3/sqlite3_utility.php +++ b/system/database/drivers/sqlite3/sqlite3_utility.php @@ -96,7 +96,8 @@ class CI_DB_sqlite3_utility extends CI_DB_utility { // Not supported return $this->db->display_error('db_unsuported_feature'); } + } /* End of file sqlite3_utility.php */ -/* Location: ./system/database/drivers/sqlite3/sqlite3_utility.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From da123732482727d33cafda557ae3047003592546 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 22:27:40 +0200 Subject: Visibility declarations and cleanup for CI_DB_oci8_driver --- system/database/drivers/oci8/oci8_driver.php | 142 +++++++++++---------------- 1 file changed, 56 insertions(+), 86 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index e3846bc1a..238a08ff8 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -1,13 +1,13 @@ -stmt_id)) { $this->stmt_id = oci_parse($this->conn_id, $sql); } } - + // -------------------------------------------------------------------- /** - * getCursor. Returns a cursor from the datbase + * Get cursor. Returns a cursor from the database * - * @access public - * @return cursor id + * @return cursor id */ public function get_cursor() { @@ -203,11 +193,10 @@ class CI_DB_oci8_driver extends CI_DB { /** * Stored Procedure. Executes a stored procedure * - * @access public - * @param package package stored procedure is in - * @param procedure stored procedure to execute - * @param params array of parameters - * @return array + * @param string package stored procedure is in + * @param string stored procedure to execute + * @param array parameters + * @return object * * params array keys * @@ -256,10 +245,9 @@ class CI_DB_oci8_driver extends CI_DB { /** * Bind parameters * - * @access private - * @return none + * @return void */ - private function _bind_params($params) + protected function _bind_params($params) { if ( ! is_array($params) OR ! is_resource($this->stmt_id)) { @@ -285,7 +273,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ public function trans_begin($test_mode = FALSE) @@ -315,7 +302,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ public function trans_commit() @@ -341,7 +327,6 @@ class CI_DB_oci8_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ public function trans_rollback() @@ -401,8 +386,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ public function affected_rows() { @@ -414,8 +398,7 @@ class CI_DB_oci8_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * @return int */ public function insert_id() { @@ -431,9 +414,8 @@ class CI_DB_oci8_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public - * @param string - * @return string + * @param string + * @return string */ public function count_all($table = '') { @@ -460,8 +442,7 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access protected - * @param boolean + * @param bool * @return string */ protected function _list_tables($prefix_limit = FALSE) @@ -483,9 +464,8 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access protected - * @param string the table name - * @return string + * @param string the table name + * @return string */ protected function _list_columns($table = '') { @@ -499,9 +479,8 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public - * @param string the table name - * @return object + * @param string the table name + * @return string */ protected function _field_data($table) { @@ -546,11 +525,10 @@ class CI_DB_oci8_driver extends CI_DB { * * This function escapes column and table names * - * @access protected * @param string * @return string */ - protected function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -589,9 +567,8 @@ class CI_DB_oci8_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access protected - * @param type - * @return type + * @param array + * @return string */ protected function _from_tables($tables) { @@ -610,11 +587,10 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ protected function _insert($table, $keys, $values) { @@ -628,10 +604,10 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ protected function _insert_batch($table, $keys, $values) { @@ -655,7 +631,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access protected * @param string the table name * @param array the update data * @param array the where clause @@ -692,7 +667,6 @@ class CI_DB_oci8_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access protected * @param string the table name * @return string */ @@ -708,7 +682,6 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access protected * @param string the table name * @param array the where clause * @param string the limit clause @@ -742,11 +715,10 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access protected - * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value - * @return string + * @param string the sql query string + * @param int the number of rows to limit the query to + * @param int the offset value + * @return string */ protected function _limit($sql, $limit, $offset) { @@ -769,16 +741,14 @@ class CI_DB_oci8_driver extends CI_DB { /** * Close DB Connection * - * @access protected - * @param resource - * @return void + * @param resource + * @return void */ protected function _close($conn_id) { @oci_close($conn_id); } - } /* End of file oci8_driver.php */ -- cgit v1.2.3-24-g4f1b From 2f56fba915e35bcc7a36fbc047503d777decccd5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 22:32:20 +0200 Subject: Visibility declarations and cleanup for OCI8 result, forge and utility classes --- system/database/drivers/oci8/oci8_forge.php | 27 ++++++++-------------- system/database/drivers/oci8/oci8_result.php | 33 +++++++++------------------ system/database/drivers/oci8/oci8_utility.php | 25 ++++++++------------ 3 files changed, 31 insertions(+), 54 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index 0a251998b..8285a29d2 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -1,13 +1,13 @@ -db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -212,12 +206,11 @@ class CI_DB_oci8_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index a14e32eec..c3f775730 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -1,13 +1,13 @@ -db->display_error('db_unsuported_feature'); } + } /* End of file oci8_utility.php */ -- cgit v1.2.3-24-g4f1b From bd44d5a7e12b8eb7f710021f92b6ffd79073cd43 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 22:59:29 +0200 Subject: Visibility declarations and cleanup for CI_DB_pdo_driver --- system/database/drivers/pdo/pdo_driver.php | 186 ++++++++++++----------------- 1 file changed, 77 insertions(+), 109 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 9b44e7c64..0295b9d56 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -1,13 +1,13 @@ -_like_escape_str = " ESCAPE '%s' "; $this->_like_escape_chr = '!'; } - - $this->trans_enabled = FALSE; + + $this->trans_enabled = FALSE; $this->_random_keyword = ' RND('.time().')'; // database specific random keyword } /** * Connection String * - * @access private * @param array * @return void */ - function _connect_string($params) + protected function _connect_string($params) { if (strpos($this->hostname, ':')) { @@ -138,7 +135,7 @@ class CI_DB_pdo_driver extends CI_DB { $this->dsn = $this->pdodriver.':'; // Add hostname to the DSN for databases that need it - if ( ! empty($this->hostname) + if ( ! empty($this->hostname) && strpos($this->hostname, ':') === FALSE && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid'))) { @@ -153,7 +150,7 @@ class CI_DB_pdo_driver extends CI_DB { } // Add the database name to the DSN, if needed - if (stripos($this->dsn, 'dbname') === FALSE + if (stripos($this->dsn, 'dbname') === FALSE && in_array($this->pdodriver, array('4D', 'pgsql', 'mysql', 'firebird', 'sybase', 'mssql', 'dblib', 'cubrid'))) { $this->dsn .= 'dbname='.$this->database.';'; @@ -190,10 +187,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class - * @return resource + * @return object */ - function db_connect() + public function db_connect() { $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; @@ -205,14 +201,13 @@ class CI_DB_pdo_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class - * @return resource + * @return object */ - function db_pconnect() + public function db_pconnect() { - $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; + $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; $this->options[PDO::ATTR_PERSISTENT] = TRUE; - + return $this->pdo_connect(); } @@ -221,23 +216,22 @@ class CI_DB_pdo_driver extends CI_DB { /** * PDO connection * - * @access private called by the PDO driver class - * @return resource + * @return object */ - function pdo_connect() + public function pdo_connect() { // Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php - if ($this->pdodriver == 'mysql' && is_php('5.3.6')) + if ($this->pdodriver === 'mysql' && ! is_php('5.3.6')) { $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '$this->dbcollat'"; } // Connecting... - try + try { $db = new PDO($this->dsn, $this->username, $this->password, $this->options); - } - catch (PDOException $e) + } + catch (PDOException $e) { if ($this->db_debug && empty($this->failover)) { @@ -258,10 +252,9 @@ class CI_DB_pdo_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ - function reconnect() + public function reconnect() { if ($this->db->db_debug) { @@ -276,10 +269,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { // Not needed for PDO return TRUE; @@ -304,16 +296,15 @@ class CI_DB_pdo_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query - * @return object + * @return mixed */ - function _execute($sql) + protected function _execute($sql) { $sql = $this->_prep_query($sql); $result_id = $this->conn_id->query($sql); - + if (is_object($result_id)) { $this->affect_rows = $result_id->rowCount(); @@ -322,7 +313,7 @@ class CI_DB_pdo_driver extends CI_DB { { $this->affect_rows = 0; } - + return $result_id; } @@ -333,11 +324,10 @@ class CI_DB_pdo_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ - function _prep_query($sql) + protected function _prep_query($sql) { if ($this->pdodriver === 'pgsql') { @@ -358,10 +348,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -387,10 +376,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -404,7 +392,7 @@ class CI_DB_pdo_driver extends CI_DB { } $ret = $this->conn->commit(); - + return $ret; } @@ -413,10 +401,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -439,12 +426,11 @@ class CI_DB_pdo_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -455,24 +441,22 @@ class CI_DB_pdo_driver extends CI_DB { return $str; } - + //Escape the string $str = $this->conn_id->quote($str); - + //If there are duplicated quotes, trim them away if (strpos($str, "'") === 0) { $str = substr($str, 1, -1); } - + // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', - $this->_like_escape_chr.'_', - $this->_like_escape_chr.$this->_like_escape_chr), - $str); + return str_replace(array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), + $str); } return $str; @@ -483,10 +467,9 @@ class CI_DB_pdo_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @return int */ - function affected_rows() + public function affected_rows() { return $this->affect_rows; } @@ -518,7 +501,6 @@ class CI_DB_pdo_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ @@ -550,11 +532,10 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean + * @param bool * @return string */ - function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { if ($this->pdodriver == 'pgsql') { @@ -573,7 +554,7 @@ class CI_DB_pdo_driver extends CI_DB { if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - return FALSE; + return FALSE; } return $sql; @@ -586,11 +567,10 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ - function _list_columns($table = '') + protected function _list_columns($table = '') { return 'SHOW COLUMNS FROM '.$this->_from_tables($table); } @@ -602,11 +582,10 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name - * @return object + * @return string */ - function _field_data($table) + protected function _field_data($table) { if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql') { @@ -623,7 +602,7 @@ class CI_DB_pdo_driver extends CI_DB { // Analog function for sqlite return 'PRAGMA table_info('.$this->_from_tables($table).')'; } - + return 'SELECT TOP 1 FROM '.$this->_from_tables($table); } @@ -663,11 +642,10 @@ class CI_DB_pdo_driver extends CI_DB { * * This function escapes column and table names * - * @access private * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -707,11 +685,10 @@ class CI_DB_pdo_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * @param array + * @return string */ - function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -728,17 +705,16 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } - + // -------------------------------------------------------------------- /** @@ -746,13 +722,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ - function _insert_batch($table, $keys, $values) + protected function _insert_batch($table, $keys, $values) { return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES '.implode(', ', $values); } @@ -764,7 +739,6 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -772,7 +746,7 @@ class CI_DB_pdo_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -788,7 +762,7 @@ class CI_DB_pdo_driver extends CI_DB { return $sql; } - + // -------------------------------------------------------------------- /** @@ -796,13 +770,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific batch update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause * @return string */ - function _update_batch($table, $values, $index, $where = NULL) + protected function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); $where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; @@ -841,7 +814,6 @@ class CI_DB_pdo_driver extends CI_DB { return $sql; } - // -------------------------------------------------------------------- /** @@ -851,11 +823,10 @@ class CI_DB_pdo_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ - function _truncate($table) + protected function _truncate($table) { return $this->_delete($table); } @@ -867,13 +838,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -902,13 +872,12 @@ class CI_DB_pdo_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ - function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite') { @@ -920,7 +889,7 @@ class CI_DB_pdo_driver extends CI_DB { { $sql .= 'LIMIT '.$limit; $sql .= ($offset > 0) ? ' OFFSET '.$offset : ''; - + return $sql; } } @@ -930,11 +899,10 @@ class CI_DB_pdo_driver extends CI_DB { /** * Close DB Connection * - * @access public * @param resource * @return void */ - function _close($conn_id) + protected function _close($conn_id) { $this->conn_id = null; } -- cgit v1.2.3-24-g4f1b From be22c5bcbea252da8133f5e3a2403f2e6bfcf90a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 23:01:53 +0200 Subject: Visibility declarations and cleanup for CI_DB_pdo_result --- system/database/drivers/pdo/pdo_result.php | 60 +++++++++++++----------------- 1 file changed, 25 insertions(+), 35 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 384b753da..5bbd85d75 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -1,13 +1,13 @@ -result_id) OR ! is_object($this->result_id)) { @@ -74,10 +71,9 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Fetch the result handler * - * @access public * @return mixed */ - function result_assoc() + public function result_assoc() { // If the result already fetched before, use that one if (count($this->result_array) > 0 OR $this->is_fetched) @@ -94,7 +90,7 @@ class CI_DB_pdo_result extends CI_DB_result { // Define the method and handler $res_method = '_fetch_'.$type; $res_handler = 'result_'.$type; - + $this->$res_handler = array(); $this->_data_seek(0); @@ -116,10 +112,9 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public - * @return integer + * @return int */ - function num_fields() + public function num_fields() { return $this->result_id->columnCount(); } @@ -131,16 +126,15 @@ class CI_DB_pdo_result extends CI_DB_result { * * Generates an array of column names * - * @access public - * @return array + * @return bool */ - function list_fields() + public function list_fields() { if ($this->db->db_debug) { return $this->db->display_error('db_unsuported_feature'); } - + return FALSE; } @@ -151,13 +145,12 @@ class CI_DB_pdo_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ - function field_data() + public function field_data() { $data = array(); - + try { if (strpos($this->result_id->queryString, 'PRAGMA') !== FALSE) @@ -173,7 +166,7 @@ class CI_DB_pdo_result extends CI_DB_result { $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL; $F->primary_key = (int) $field['pk']; $F->pdo_type = NULL; - + $data[] = $F; } } @@ -188,7 +181,7 @@ class CI_DB_pdo_result extends CI_DB_result { $F->type = $field['native_type']; $F->default = NULL; $F->pdo_type = $field['pdo_type']; - + if ($field['precision'] < 0) { $F->max_length = NULL; @@ -203,7 +196,7 @@ class CI_DB_pdo_result extends CI_DB_result { $data[] = $F; } } - + return $data; } catch (Exception $e) @@ -222,9 +215,9 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ - function free_result() + public function free_result() { if (is_object($this->result_id)) { @@ -237,14 +230,13 @@ class CI_DB_pdo_result extends CI_DB_result { /** * Data Seek * - * Moves the internal pointer to the desired offset. We call + * Moves the internal pointer to the desired offset. We call * this internally before fetching results to make sure the * result set starts at zero * - * @access private - * @return array + * @return bool */ - function _data_seek($n = 0) + protected function _data_seek($n = 0) { return FALSE; } @@ -256,10 +248,9 @@ class CI_DB_pdo_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ - function _fetch_assoc() + protected function _fetch_assoc() { return $this->result_id->fetch(PDO::FETCH_ASSOC); } @@ -271,11 +262,10 @@ class CI_DB_pdo_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ - function _fetch_object() - { + protected function _fetch_object() + { return $this->result_id->fetchObject(); } -- cgit v1.2.3-24-g4f1b From 9fd79f568beb10194f3de66b14a484c2dddcaa95 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 23:04:13 +0200 Subject: Visibility declarations and cleanup for PDO forge and utility classes --- system/database/drivers/pdo/pdo_forge.php | 32 +++++++++++------------------ system/database/drivers/pdo/pdo_utility.php | 24 ++++++++-------------- 2 files changed, 21 insertions(+), 35 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 2e5c81de3..6bff3542f 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -1,13 +1,13 @@ -db->db_debug) @@ -212,17 +206,16 @@ class CI_DB_pdo_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name * @param string the column definition * @param string the default value - * @param boolean should 'NOT NULL' be added + * @param bool should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name); @@ -265,12 +258,11 @@ class CI_DB_pdo_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php index c278c5172..86c798397 100644 --- a/system/database/drivers/pdo/pdo_utility.php +++ b/system/database/drivers/pdo/pdo_utility.php @@ -1,13 +1,13 @@ -db->db_debug) @@ -59,11 +56,10 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be optimized * - * @access private * @param string the table name - * @return object + * @return bool */ - function _optimize_table($table) + public function _optimize_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -80,11 +76,10 @@ class CI_DB_pdo_utility extends CI_DB_utility { * * Generates a platform-specific query so that a table can be repaired * - * @access private * @param string the table name - * @return object + * @return bool */ - function _repair_table($table) + public function _repair_table($table) { // Not a supported PDO feature if ($this->db->db_debug) @@ -99,11 +94,10 @@ class CI_DB_pdo_utility extends CI_DB_utility { /** * PDO Export * - * @access private * @param array Preferences * @return mixed */ - function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 131772cbf8f19bc4f470f5abbdbe3f89125659d3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 23:35:03 +0200 Subject: Some small improvements to CI_DB_interbase_driver --- .../drivers/interbase/interbase_driver.php | 145 +++++++-------------- 1 file changed, 49 insertions(+), 96 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 9fa03adc7..977a84ecb 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Firebird/Interbase Database Adapter Class * @@ -56,8 +54,8 @@ class CI_DB_interbase_driver extends CI_DB { * database engines, so this string appears in each driver and is * used for the count_all() and count_all_results() functions. */ - protected $_count_string = "SELECT COUNT(*) AS "; - protected $_random_keyword = ' Random()'; // database specific random keyword + protected $_count_string = 'SELECT COUNT(*) AS '; + protected $_random_keyword = ' Random()'; // database specific random keyword // Keeps track of the resource for the current transaction protected $trans; @@ -160,13 +158,8 @@ class CI_DB_interbase_driver extends CI_DB { */ public function trans_begin($test_mode = FALSE) { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } @@ -174,7 +167,7 @@ class CI_DB_interbase_driver extends CI_DB { // Reset the transaction failure flag. // If the $test_mode flag is set to TRUE transactions will be rolled back // even if the queries produce a successful result. - $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + $this->_trans_failure = ($test_mode === TRUE); $this->trans = @ibase_trans($this->conn_id); @@ -190,13 +183,8 @@ class CI_DB_interbase_driver extends CI_DB { */ public function trans_commit() { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans->depth > 0) { return TRUE; } @@ -213,13 +201,8 @@ class CI_DB_interbase_driver extends CI_DB { */ public function trans_rollback() { - if ( ! $this->trans_enabled) - { - return TRUE; - } - // When transactions are nested we only begin/commit/rollback the outermost ones - if ($this->_trans_depth > 0) + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) { return TRUE; } @@ -251,9 +234,9 @@ class CI_DB_interbase_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), - $str); + return str_replace(array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), + $str); } return $str; @@ -264,7 +247,7 @@ class CI_DB_interbase_driver extends CI_DB { /** * Affected Rows * - * @return integer + * @return int */ public function affected_rows() { @@ -276,9 +259,9 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * @param string $generator_name - * @param integer $inc_by - * @return integer + * @param string $generator_name + * @param int $inc_by + * @return int */ public function insert_id($generator_name, $inc_by=0) { @@ -310,9 +293,9 @@ class CI_DB_interbase_driver extends CI_DB { return 0; } - $row = $query->row(); + $query = $query->row(); $this->_reset_select(); - return (int) $row->numrows; + return (int) $query->numrows; } // -------------------------------------------------------------------- @@ -322,21 +305,18 @@ class CI_DB_interbase_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @param boolean + * @param bool * @return string */ protected function _list_tables($prefix_limit = FALSE) { - $sql = <<dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix != '') { - $sql .= ' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); + return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } + return $sql; } @@ -352,10 +332,7 @@ SQL; */ protected function _list_columns($table = '') { - return <<escape_str($table)."'"; } // -------------------------------------------------------------------- @@ -366,14 +343,14 @@ SQL; * Generates a platform-specific query so that the column data can be retrieved * * @param string the table name - * @return object + * @return string */ protected function _field_data($table) { // Need to find a more efficient way to do this // but Interbase/Firebird seems to lack the // limit clause - return "SELECT * FROM {$table}"; + return 'SELECT * FROM '.$table; } // -------------------------------------------------------------------- @@ -407,24 +384,20 @@ SQL; { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + $item = str_replace('.', $this->_escape_char.'.', $item); // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item); } } if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; - } - else - { - $str = $this->_escape_char.$item.$this->_escape_char; + $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item); } // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char); } // -------------------------------------------------------------------- @@ -435,8 +408,8 @@ SQL; * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @param type - * @return type + * @param array + * @return string */ protected function _from_tables($tables) { @@ -463,7 +436,7 @@ SQL; */ protected function _insert($table, $keys, $values) { - return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; + return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } // -------------------------------------------------------------------- @@ -484,20 +457,14 @@ SQL; { foreach ($values as $key => $val) { - $valstr[] = $key." = ".$val; + $valstr[] = $key.' = '.$val; } //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - - $sql = "UPDATE {$table} SET ".implode(', ', $valstr); - - $sql .= ($where != '' AND count($where) >=1) ? ' WHERE '.implode(' ', $where) : ''; - - $sql .= $orderby; - - return $sql; + return 'UPDATE '.$table.' SET '.implode(', ', $valstr) + .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '') + .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : ''); } @@ -532,23 +499,20 @@ SQL; */ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { - $conditions = ''; - if (count($where) > 0 OR count($like) > 0) { - $conditions = "\nWHERE "; - $conditions .= implode("\n", $this->ar_where); - - if (count($where) > 0 && count($like) > 0) - { - $conditions .= ' AND '; - } - $conditions .= implode("\n", $like); + $conditions = "\nWHERE ".implode("\n", $where) + .((count($where) > 0 && count($like) > 0) ? ' AND ' : '') + .implode("\n", $like); + } + else + { + $conditions = ''; } //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - return "DELETE FROM {$table}{$conditions}"; + return 'DELETE FROM '.$table.' '.$conditions; } // -------------------------------------------------------------------- @@ -559,36 +523,25 @@ SQL; * Generates a platform-specific LIMIT clause * * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value + * @param int the number of rows to limit the query to + * @param int the offset value * @return string */ protected function _limit($sql, $limit, $offset) { - // Keep the current sql string safe for a moment - $orig_sql = $sql; - // Limit clause depends on if Interbase or Firebird if (stripos($this->version(), 'firebird') !== FALSE) { - $sql = 'FIRST '. (int) $limit; - - if ($offset > 0) - { - $sql .= ' SKIP '. (int) $offset; - } + $select = 'FIRST '. (int) $limit + .($offset > 0 ? ' SKIP '. (int) $offset : ''); } else { - $sql = 'ROWS ' . (int) $limit; - - if ($offset > 0) - { - $sql = 'ROWS '. (int) $offset . ' TO ' . ($limit + $offset); - } + $select = 'ROWS ' + .($offset > 0 ? (int) $offset.' TO '.($limit + $offset) : (int) $limit); } - return preg_replace('`SELECT`i', "SELECT {$sql}", $orig_sql); + return preg_replace('`SELECT`i', 'SELECT '.$select, $sql); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 60c9c9990f635309965929e73d0bfe52d46253ca Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 23:46:09 +0200 Subject: Some small improvements to CI_DB_interbase_result --- .../drivers/interbase/interbase_driver.php | 2 +- .../drivers/interbase/interbase_result.php | 85 +++++++++------------- 2 files changed, 35 insertions(+), 52 deletions(-) (limited to 'system') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 977a84ecb..326841dc2 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -310,7 +310,7 @@ class CI_DB_interbase_driver extends CI_DB { */ protected function _list_tables($prefix_limit = FALSE) { - $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB\$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\''; + $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\''; if ($prefix_limit !== FALSE && $this->dbprefix != '') { diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 5bf0c902d..fd4178dec 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Interbase/Firebird Result Class * @@ -43,18 +41,18 @@ class CI_DB_interbase_result extends CI_DB_result { /** * Number of rows in the result set * - * @return integer + * @return int */ public function num_rows() { - if( ! is_null($this->num_rows)) + if (is_int($this->num_rows)) { return $this->num_rows; } - - //Get the results so that you can get an accurate rowcount + + // Get the results so that you can get an accurate rowcount $this->result(); - + return $this->num_rows; } @@ -63,7 +61,7 @@ class CI_DB_interbase_result extends CI_DB_result { /** * Number of fields in the result set * - * @return integer + * @return int */ public function num_fields() { @@ -102,20 +100,17 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function field_data() { - $retval = array(); - for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++) + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) { $info = ibase_field_info($this->result_id, $i); - - $F = new stdClass(); - $F->name = $info['name']; - $F->type = $info['type']; - $F->max_length = $info['length']; - $F->primary_key = 0; - $F->default = ''; - - $retval[] = $F; + + $retval[$i] = new stdClass(); + $retval[$i]->name = $info['name']; + $retval[$i]->type = $info['type']; + $retval[$i]->max_length = $info['length']; + $retval[$i]->primary_key = 0; + $retval[$i]->default = ''; } return $retval; @@ -126,7 +121,7 @@ class CI_DB_interbase_result extends CI_DB_result { /** * Free the result * - * @return null + * @return void */ public function free_result() { @@ -138,7 +133,7 @@ class CI_DB_interbase_result extends CI_DB_result { /** * Data Seek * - * Moves the internal pointer to the desired offset. We call + * Moves the internal pointer to the desired offset. We call * this internally before fetching results to make sure the * result set starts at zero * @@ -146,11 +141,8 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _data_seek($n = 0) { - //Set the row count to 0 - $this->num_rows = 0; - - //Interbase driver doesn't implement a suitable function - return FALSE; + // Interbase driver doesn't implement a suitable function + return FALSE; } // -------------------------------------------------------------------- @@ -169,7 +161,7 @@ class CI_DB_interbase_result extends CI_DB_result { //Increment row count $this->num_rows++; } - + return $row; } @@ -189,10 +181,10 @@ class CI_DB_interbase_result extends CI_DB_result { //Increment row count $this->num_rows++; } - + return $row; } - + // -------------------------------------------------------------------- /** @@ -202,29 +194,20 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function result_object() { - if (count($this->result_object) > 0) + if (count($this->result_object) === $this->num_rows) { return $this->result_object; } - - // Convert result array to object so that + + // Convert result array to object so that // We don't have to get the result again - if (count($this->result_array) > 0) + if (($c = count($this->result_array)) > 0) { - $i = 0; - - foreach ($this->result_array as $array) + for ($i = 0; $i < $c; $i++) { - $this->result_object[$i] = new StdClass(); - - foreach ($array as $key => $val) - { - $this->result_object[$i]->{$key} = $val; - } - - ++$i; + $this->result_object[$i] = (object) $this->result_array[$i]; } - + return $this->result_object; } @@ -254,20 +237,20 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function result_array() { - if (count($this->result_array) > 0) + if (count($this->result_array) === $this->num_rows) { return $this->result_array; } - + // Since the object and array are really similar, just case // the result object to an array if need be - if (count($this->result_object) > 0) + if (($c = count($this->result_object)) > 0) { - foreach ($this->result_object as $obj) + for ($i = 0; $i < $c; $i++) { - $this->result_array[] = (array) $obj; + $this->result_array[$i] = (array) $this->result_object[$i]; } - + return $this->result_array; } -- cgit v1.2.3-24-g4f1b From b455294bc404e41a65f8c9260837e76ee1cc9bda Mon Sep 17 00:00:00 2001 From: leandronf Date: Wed, 21 Mar 2012 23:54:26 -0300 Subject: (DSN) Delivery status notification feature --- system/libraries/Email.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f30fe40b6..d870f9782 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -59,6 +59,7 @@ class CI_Email { public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. + var $dsn = FALSE"; // Delivery Status Notification public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch @@ -1567,9 +1568,11 @@ class CI_Email { $resp = 250; break; case 'to' : - - $this->_send_data('RCPT TO:<'.$data.'>'); - + + if($this->dsn) + $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + else + $this->_send_data('RCPT TO:<'.$data.'>'); $resp = 250; break; case 'data' : -- cgit v1.2.3-24-g4f1b From 7686c1208cf1b0d9e1f4e522fff8a4b4646b7a2d Mon Sep 17 00:00:00 2001 From: leandronf Date: Thu, 22 Mar 2012 08:07:31 -0300 Subject: Update system/libraries/Email.php --- system/libraries/Email.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index d870f9782..8f383c939 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -59,7 +59,7 @@ class CI_Email { public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. - var $dsn = FALSE"; // Delivery Status Notification + public $dsn = FALSE; // Delivery Status Notification public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch @@ -1569,10 +1569,14 @@ class CI_Email { break; case 'to' : - if($this->dsn) + if ($this->dsn) + { $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + } else + { $this->_send_data('RCPT TO:<'.$data.'>'); + } $resp = 250; break; case 'data' : -- cgit v1.2.3-24-g4f1b From 2cae193647045a83014972d2aae908e7ea0ac8f3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 23 Mar 2012 16:08:41 +0200 Subject: Add dummy method reconnect() method to CI_DB_driver and remove it from drivers that don't support it --- system/database/DB_driver.php | 17 +++++++++++++++++ .../database/drivers/interbase/interbase_driver.php | 15 --------------- system/database/drivers/mssql/mssql_driver.php | 15 --------------- system/database/drivers/oci8/oci8_driver.php | 16 ---------------- system/database/drivers/odbc/odbc_driver.php | 15 --------------- system/database/drivers/pdo/pdo_driver.php | 20 -------------------- system/database/drivers/sqlite/sqlite_driver.php | 15 --------------- system/database/drivers/sqlsrv/sqlsrv_driver.php | 15 --------------- 8 files changed, 17 insertions(+), 111 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 42b1b35aa..9f1a0b895 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -170,6 +170,23 @@ abstract class CI_DB_driver { // -------------------------------------------------------------------- + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout. + * + * This is just a dummy method to allow drivers without such + * functionality to not declare it, while others will override it. + * + * @return void + */ + public function reconnect() + { + } + + // -------------------------------------------------------------------- + /** * Set client character set * diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 326841dc2..d8b6ae571 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -84,21 +84,6 @@ class CI_DB_interbase_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - // not implemented in Interbase/Firebird - } - - // -------------------------------------------------------------------- - /** * Select the database * diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 1c1b84582..f2933fe43 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -91,21 +91,6 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - // not implemented in MSSQL - } - - // -------------------------------------------------------------------- - /** * Select the database * diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 238a08ff8..c9e791d63 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -102,22 +102,6 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - // not implemented in oracle - return; - } - - // -------------------------------------------------------------------- - /** * Select the database * diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 6704264c6..901787ff3 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -89,21 +89,6 @@ class CI_DB_odbc_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - // not implemented in odbc - } - - // -------------------------------------------------------------------- - /** * Select the database * diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 0295b9d56..19338e30f 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -246,26 +246,6 @@ class CI_DB_pdo_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - if ($this->db->db_debug) - { - return $this->db->display_error('db_unsuported_feature'); - } - - return FALSE; - } - - // -------------------------------------------------------------------- - /** * Select the database * diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index bb86c2296..fa7e4846a 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -105,21 +105,6 @@ class CI_DB_sqlite_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - // not implemented in SQLite - } - - // -------------------------------------------------------------------- - /** * Select the database * diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 2b9f82201..9f2f88699 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -100,21 +100,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - // not implemented in MSSQL - } - - // -------------------------------------------------------------------- - /** * Select the database * -- cgit v1.2.3-24-g4f1b From 0fd760e9765ea6785b4bd59d65365a079717ca6a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 23 Mar 2012 16:10:01 +0200 Subject: Remove no longer needed reconnect() method --- system/database/drivers/sqlite3/sqlite3_driver.php | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index a3f5191b4..39d1e2141 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -91,21 +91,6 @@ class CI_DB_sqlite3_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Reconnect - * - * Keep / reestablish the db connection if no queries have been - * sent for a length of time exceeding the server's idle timeout - * - * @return void - */ - public function reconnect() - { - // Not supported - } - - // -------------------------------------------------------------------- - /** * Select the database * -- cgit v1.2.3-24-g4f1b From c3b36f4c6b8e8b15c96d6653ebdf07c76eb57d9e Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Mon, 26 Mar 2012 10:27:17 +0200 Subject: Centralize handling of attach() function for both real file and buffer string. Update documentation. --- system/libraries/Email.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 7320ea566..7429035f8 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -83,7 +83,6 @@ class CI_Email { protected $_attach_name = array(); protected $_attach_type = array(); protected $_attach_disp = array(); - protected $_attach_content = array(); protected $_protocols = array('mail', 'sendmail', 'smtp'); protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) protected $_bit_depths = array('7bit', '8bit'); @@ -172,7 +171,6 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); - $this->_attach_content = array(); } return $this; @@ -408,12 +406,11 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $disposition = '', $str = '', $mime = '', $newname = NULL) + public function attach($filename, $disposition = '', $newname = NULL, $mime = '') { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = ($mime == '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters - $this->_attach_content[] = $str; + $this->_attach_type[] = $mime; return $this; } @@ -1053,7 +1050,7 @@ class CI_Email { $ctype = $this->_attach_type[$i]; $file_content = ''; - if ($this->_attach_content[$i] === '') + if ($this->_attach_type[$i] == '') { if ( ! file_exists($filename)) { @@ -1069,6 +1066,7 @@ class CI_Email { return FALSE; } + $ctype = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); $file_content = fread($fp, $file); fclose($fp); } -- cgit v1.2.3-24-g4f1b From 94708bd62022f9a0cfb06d2f26e8441b6c4c562c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 12:09:28 +0300 Subject: Alter SQLite's escape_str() for LIKE queries --- system/database/drivers/sqlite/sqlite_driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index fa7e4846a..08b074cca 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -245,9 +245,9 @@ class CI_DB_sqlite_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - $str = str_replace( array('%', '_', $this->_like_escape_chr), - array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), - $str); + return str_replace(array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_') + $str); } return $str; -- cgit v1.2.3-24-g4f1b From 830f5af4bac8da4b6f9392334348bc9e33b09240 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 12:11:38 +0300 Subject: Add a missing comma --- system/database/drivers/sqlite/sqlite_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 08b074cca..102c79bb3 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -246,7 +246,7 @@ class CI_DB_sqlite_driver extends CI_DB { if ($like === TRUE) { return str_replace(array($this->_like_escape_chr, '%', '_'), - array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_') + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), $str); } -- cgit v1.2.3-24-g4f1b From a00e50483ab27d8ba3d3a2aa1a5138bfa8c8be70 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 12:23:13 +0300 Subject: Add DSN string and persistent connections support for CUBRID --- system/database/drivers/cubrid/cubrid_driver.php | 85 ++++++++++++++++-------- 1 file changed, 56 insertions(+), 29 deletions(-) (limited to 'system') diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index f39c2ad76..bed3d8685 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -57,38 +57,35 @@ class CI_DB_cubrid_driver extends CI_DB { protected $_count_string = 'SELECT COUNT(*) AS '; protected $_random_keyword = ' RAND()'; // database specific random keyword - /** - * Non-persistent database connection - * - * @return resource - */ - public function db_connect() - { - // If no port is defined by the user, use the default value - if ($this->port == '') - { - // Default CUBRID Broker port - $this->port = 33000; - } + // CUBRID-specific properties + public $auto_commit = TRUE; - $conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password); + public function __construct($params) + { + parent::__construct($params); - if ($conn) + if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\?.+)?$/', $this->dsn, $matches)) { - // Check if a user wants to run queries in dry, i.e. run the - // queries but not commit them. - if (isset($this->auto_commit) && ! $this->auto_commit) + if (stripos($matches[2], 'autocommit=off') !== FALSE) { - cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_FALSE); - } - else - { - cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_TRUE); - $this->auto_commit = TRUE; + $this->auto_commit = FALSE; } } + else + { + // If no port is defined by the user, use the default value + $this->port == '' OR $this->port = 33000; + } + } - return $conn; + /** + * Non-persistent database connection + * + * @return resource + */ + public function db_connect() + { + return $this->_cubrid_connect(); } // -------------------------------------------------------------------- @@ -100,15 +97,45 @@ class CI_DB_cubrid_driver extends CI_DB { * engine which can be configured in the CUBRID Broker configuration * file by setting the CCI_PCONNECT parameter to ON. In that case, all * connections established between the client application and the - * server will become persistent. This is calling the same - * @cubrid_connect function will establish persisten connection - * considering that the CCI_PCONNECT is ON. + * server will become persistent. * * @return resource */ public function db_pconnect() { - return $this->db_connect(); + return $this->_cubrid_connect(TRUE); + } + + // -------------------------------------------------------------------- + + /** + * CUBRID connection + * + * A CUBRID-specific method to create a connection to the database. + * Except for determining if a persistent connection should be used, + * the rest of the logic is the same for db_connect() and db_pconnect(). + * + * @param bool + * @return resource + */ + protected function _cubrid_connect($persistent = FALSE) + { + if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches)) + { + $_temp = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url'; + $conn_id = ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '') + ? $_temp($this->dsn, $this->username, $this->password) + : $_temp($this->dsn); + } + else + { + $_temp = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect'; + $conn_id = ($this->username !== '') + ? $_temp($this->hostname, $this->port, $this->database, $this->username, $this->password) + : $_temp($this->hostname, $this->port, $this->database); + } + + return $conn_id; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 6192bc0cd34e214d5287ba45994d84789def31af Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 12:32:32 +0300 Subject: Improve PostgreSQL DSN string support and add a missing method visibility declaration --- system/database/drivers/postgre/postgre_driver.php | 71 ++++++++++++++++------ .../database/drivers/postgre/postgre_utility.php | 2 +- 2 files changed, 54 insertions(+), 19 deletions(-) (limited to 'system') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 3bfccad05..3e2d05ce8 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -57,29 +57,64 @@ class CI_DB_postgre_driver extends CI_DB { protected $_random_keyword = ' RANDOM()'; // database specific random keyword /** - * Connection String + * Constructor * - * @return string + * Creates a DSN string to be used for db_connect() and db_pconnect() + * + * @return void */ - protected function _connect_string() + public function __construct($params) { - $components = array( - 'hostname' => 'host', - 'port' => 'port', - 'database' => 'dbname', - 'username' => 'user', - 'password' => 'password' - ); - - $connect_string = ""; - foreach ($components as $key => $val) + parent::__construct($params); + + if ( ! empty($this->dsn)) + { + return; + } + + $this->dsn === '' OR $this->dsn = ''; + + if (strpos($this->hostname, '/') !== FALSE) + { + // If UNIX sockets are used, we shouldn't set a port + $this->port = ''; + } + + $this->hostname === '' OR $this->dsn = 'host='.$this->hostname; + + if ( ! empty($this->port) && ctype_digit($this->port)) + { + $this->dsn .= 'host='.$this->port.' '; + } + + if ($this->username !== '') { - if (isset($this->$key) && $this->$key != '') + $this->dsn .= 'username='.$this->username.' '; + + /* An empty password is valid! + * + * $db['password'] = NULL must be done in order to ignore it. + */ + $this->password === NULL OR $this->dsn .= "password='".$this->password."' "; + } + + $this->database === '' OR $this->dsn .= 'dbname='.$this->database.' '; + + /* We don't have these options as elements in our standard configuration + * array, but they might be set by parse_url() if the configuration was + * provided via string. Example: + * + * postgre://username:password@localhost:5432/database?connect_timeout=5&sslmode=1 + */ + foreach (array('connect_timeout', 'options', 'sslmode', 'service') as $key) + { + if (isset($this->$key) && is_string($this->key) && $this->key !== '') { - $connect_string .= " $val=".$this->$key; + $this->dsn .= $key."='".$this->key."' "; } } - return trim($connect_string); + + $this->dsn = rtrim($this->dsn); } // -------------------------------------------------------------------- @@ -91,7 +126,7 @@ class CI_DB_postgre_driver extends CI_DB { */ public function db_connect() { - return @pg_connect($this->_connect_string()); + return @pg_connect($this->dsn); } // -------------------------------------------------------------------- @@ -103,7 +138,7 @@ class CI_DB_postgre_driver extends CI_DB { */ public function db_pconnect() { - return @pg_pconnect($this->_connect_string()); + return @pg_pconnect($this->dsn); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index c6b71b4d9..cf29201ff 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -78,7 +78,7 @@ class CI_DB_postgre_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 9a1fc2013e876347e9c8d336bade7ac589712bf7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 12:38:34 +0300 Subject: Add ODBC support for the new 'dsn' config value --- system/database/drivers/odbc/odbc_driver.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 901787ff3..ad773117f 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -57,12 +57,17 @@ class CI_DB_odbc_driver extends CI_DB { protected $_count_string = 'SELECT COUNT(*) AS '; protected $_random_keyword; - public function __construct($params) { parent::__construct($params); $this->_random_keyword = ' RND('.time().')'; // database specific random keyword + + // Legacy support for DSN in the hostname field + if ($this->dsn == '') + { + $this->dsn = $this->hostname; + } } /** @@ -72,7 +77,7 @@ class CI_DB_odbc_driver extends CI_DB { */ public function db_connect() { - return @odbc_connect($this->hostname, $this->username, $this->password); + return @odbc_connect($this->dsn, $this->username, $this->password); } // -------------------------------------------------------------------- @@ -84,7 +89,7 @@ class CI_DB_odbc_driver extends CI_DB { */ public function db_pconnect() { - return @odbc_pconnect($this->hostname, $this->username, $this->password); + return @odbc_pconnect($this->dsn, $this->username, $this->password); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 59ad0af04debb4e10e20fbdfc1827a620a88b7be Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 12:47:45 +0300 Subject: Add DSN string support for Oracle --- system/database/drivers/oci8/oci8_driver.php | 87 +++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index c9e791d63..3bc8c114c 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -78,6 +78,85 @@ class CI_DB_oci8_driver extends CI_DB { // throw off num_fields later public $limit_used; + public function __construct($params) + { + parent::__construct($params); + + $valid_dsns = array( + 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS + // Easy Connect string (Oracle 10g+) + 'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i', + 'in' => '/^[a-z0-9$_]+$/i' // Instance name (defined in tnsnames.ora) + ); + + /* Space characters don't have any effect when actually + * connecting, but can be a hassle while validating the DSN. + */ + $this->dsn = str_replace(array("\n", "\r", "\t", ' '), '', $this->dsn); + + if ($this->dsn !== '') + { + foreach ($valid_dsns as $regexp) + { + if (preg_match($regexp, $this->dsn)) + { + return; + } + } + } + + // Legacy support for TNS in the hostname configuration field + $this->hostname = str_replace(array("\n", "\r", "\t", ' '), '', $this->hostname); + if (preg_match($valid_dsns['tns'], $this->hostname)) + { + $this->dsn = $this->hostname; + return; + } + elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE + && (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== '')) + { + /* If the hostname field isn't empty, doesn't contain + * ':' and/or '/' and if port and/or database aren't + * empty, then the hostname field is most likely indeed + * just a hostname. Therefore we'll try and build an + * Easy Connect string from these 3 settings, assuming + * that the database field is a service name. + */ + $this->dsn = $this->hostname + .(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '') + .($this->database !== '' ? '/'.ltrim($this->database, '/') : ''); + + if (preg_match($valid_dsns['ec'], $this->dsn)) + { + return; + } + } + + /* At this point, we can only try and validate the hostname and + * database fields separately as DSNs. + */ + if (preg_match($valid_dsns['ec'], $this->hostname) OR preg_match($valid_dsns['in'], $this->hostname)) + { + $this->dsn = $this->hostname; + return; + } + + $this->database = str_replace(array("\n", "\r", "\t", ' '), '', $this->database); + foreach ($valid_dsns as $regexp) + { + if (preg_match($regexp, $this->database)) + { + return; + } + } + + /* Well - OK, an empty string should work as well. + * PHP will try to use environment variables to + * determine which Oracle instance to connect to. + */ + $this->dsn = ''; + } + /** * Non-persistent database connection * @@ -85,7 +164,9 @@ class CI_DB_oci8_driver extends CI_DB { */ public function db_connect() { - return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set); + return ( ! empty($this->char_set)) + ? @oci_connect($this->username, $this->password, $this->dsn, $this->char_set) + : @oci_connect($this->username, $this->password, $this->dsn); } // -------------------------------------------------------------------- @@ -97,7 +178,9 @@ class CI_DB_oci8_driver extends CI_DB { */ public function db_pconnect() { - return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set); + return ( ! empty($this->char_set)) + ? @oci_pconnect($this->username, $this->password, $this->dsn, $this->char_set) + : @oci_pconnect($this->username, $this->password, $this->dsn); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From c2697db0f2721cc9fefb58b85bf55e6bdb91db9b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 13:05:24 +0300 Subject: Rename a variable and style fixes in system/database/DB.php --- system/database/DB.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'system') diff --git a/system/database/DB.php b/system/database/DB.php index 116116bf4..96e495515 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -37,11 +37,11 @@ function &DB($params = '', $active_record_override = NULL) { // Load the DB config file if a DSN string wasn't passed - if (is_string($params) AND strpos($params, '://') === FALSE) + if (is_string($params) && strpos($params, '://') === FALSE) { // Is the config file in the environment folder? if (( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')) - AND ! file_exists($file_path = APPPATH.'config/database.php')) + && ! file_exists($file_path = APPPATH.'config/database.php')) { show_error('The configuration file database.php does not exist.'); } @@ -74,24 +74,24 @@ function &DB($params = '', $active_record_override = NULL) * parameter. DSNs must have this prototype: * $dsn = 'driver://username:password@hostname/database'; */ - if (($dns = @parse_url($params)) === FALSE) + if (($dsn = @parse_url($params)) === FALSE) { show_error('Invalid DB Connection String'); } $params = array( - 'dbdriver' => $dns['scheme'], - 'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '', - 'port' => (isset($dns['port'])) ? rawurldecode($dns['port']) : '', - 'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '', - 'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '', - 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : '' + 'dbdriver' => $dsn['scheme'], + 'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '', + 'port' => isset($dsn['port']) ? rawurldecode($dsn['port']) : '', + 'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '', + 'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '', + 'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : '' ); // were additional config items set? - if (isset($dns['query'])) + if (isset($dsn['query'])) { - parse_str($dns['query'], $extra); + parse_str($dsn['query'], $extra); foreach ($extra as $key => $val) { // booleans please @@ -158,4 +158,4 @@ function &DB($params = '', $active_record_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From e684bdac2d6282e3b9a5c57e1006d5ed1664f647 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 13:47:29 +0300 Subject: Clear some spaces and fix some inconsistencies in the Zip library and system/helpers/ files --- system/helpers/captcha_helper.php | 4 +--- system/helpers/date_helper.php | 2 +- system/helpers/smiley_helper.php | 13 ++++++------- system/helpers/string_helper.php | 10 +++++----- system/helpers/text_helper.php | 8 ++++---- system/libraries/Zip.php | 8 ++++---- 6 files changed, 21 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 578796573..5955e054a 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -1,4 +1,4 @@ -now); - + $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; -- cgit v1.2.3-24-g4f1b From c6a68e04169802c8aa82e41634ce350eafd1ec1e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:30:10 +0300 Subject: Add visibility declarations where they remain missing --- system/core/Exceptions.php | 6 ++---- system/database/drivers/mssql/mssql_driver.php | 3 +-- system/database/drivers/pdo/pdo_driver.php | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index d7282b1f3..f36b31598 100755 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Exceptions Class * @@ -163,7 +161,7 @@ class CI_Exceptions { * @param string the error line number * @return string */ - function show_php_error($severity, $message, $filepath, $line) + public function show_php_error($severity, $message, $filepath, $line) { $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; $filepath = str_replace('\\', '/', $filepath); @@ -189,4 +187,4 @@ class CI_Exceptions { } /* End of file Exceptions.php */ -/* Location: ./system/core/Exceptions.php */ +/* Location: ./system/core/Exceptions.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index f2933fe43..912808631 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -539,13 +539,12 @@ class CI_DB_mssql_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 19338e30f..f336eb0ab 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -484,7 +484,7 @@ class CI_DB_pdo_driver extends CI_DB { * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { -- cgit v1.2.3-24-g4f1b From a5dd2976044b856a875d50e612a2b39ae05787ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:43:01 +0300 Subject: Make _initialize() a constructor and rename _call_hook() to call_hook in the Hooks class --- system/core/CodeIgniter.php | 14 +++++++------- system/core/Hooks.php | 32 ++++++++++++-------------------- 2 files changed, 19 insertions(+), 27 deletions(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index a79a69590..4885f310c 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -133,7 +133,7 @@ * Is there a "pre_system" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('pre_system'); + $EXT->call_hook('pre_system'); /* * ------------------------------------------------------ @@ -194,7 +194,7 @@ * Is there a valid cache file? If so, we're done... * ------------------------------------------------------ */ - if ($EXT->_call_hook('cache_override') === FALSE + if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) == TRUE) { exit; @@ -297,7 +297,7 @@ * Is there a "pre_controller" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('pre_controller'); + $EXT->call_hook('pre_controller'); /* * ------------------------------------------------------ @@ -314,7 +314,7 @@ * Is there a "post_controller_constructor" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('post_controller_constructor'); + $EXT->call_hook('post_controller_constructor'); /* * ------------------------------------------------------ @@ -369,14 +369,14 @@ * Is there a "post_controller" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('post_controller'); + $EXT->call_hook('post_controller'); /* * ------------------------------------------------------ * Send the final rendered output to the browser * ------------------------------------------------------ */ - if ($EXT->_call_hook('display_override') === FALSE) + if ($EXT->call_hook('display_override') === FALSE) { $OUT->_display(); } @@ -386,7 +386,7 @@ * Is there a "post_system" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('post_system'); + $EXT->call_hook('post_system'); /* * ------------------------------------------------------ diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 493822f36..68e30ef0f 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Hooks Class * @@ -51,7 +49,7 @@ class CI_Hooks { * * @var array */ - public $hooks = array(); + public $hooks = array(); /** * Determines wether hook is in progress, used to prevent infinte loops * @@ -59,23 +57,17 @@ class CI_Hooks { */ public $in_progress = FALSE; - public function __construct() - { - $this->_initialize(); - log_message('debug', 'Hooks Class Initialized'); - } - - // -------------------------------------------------------------------- - /** * Initialize the Hooks Preferences * * @return void */ - private function _initialize() + public function __construct() { $CFG =& load_class('Config', 'core'); + log_message('debug', 'Hooks Class Initialized'); + // If hooks are not enabled in the config file // there is nothing else to do if ($CFG->item('enable_hooks') == FALSE) @@ -84,7 +76,7 @@ class CI_Hooks { } // Grab the "hooks" definition file. - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'); } @@ -113,14 +105,14 @@ class CI_Hooks { * @param string the hook name * @return mixed */ - public function _call_hook($which = '') + public function call_hook($which = '') { if ( ! $this->enabled OR ! isset($this->hooks[$which])) { return FALSE; } - if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0])) + if (isset($this->hooks[$which][0]) && is_array($this->hooks[$which][0])) { foreach ($this->hooks[$which] as $val) { @@ -167,7 +159,7 @@ class CI_Hooks { // Set file path // ----------------------------------- - if ( ! isset($data['filepath']) OR ! isset($data['filename'])) + if ( ! isset($data['filepath'], $data['filename'])) { return FALSE; } @@ -187,12 +179,12 @@ class CI_Hooks { $function = FALSE; $params = ''; - if (isset($data['class']) AND $data['class'] != '') + if ( ! empty($data['class'])) { $class = $data['class']; } - if (isset($data['function'])) + if ( ! empty($data['function'])) { $function = $data['function']; } @@ -202,7 +194,7 @@ class CI_Hooks { $params = $data['params']; } - if ($class === FALSE AND $function === FALSE) + if ($class === FALSE && $function === FALSE) { return FALSE; } @@ -244,4 +236,4 @@ class CI_Hooks { } /* End of file Hooks.php */ -/* Location: ./system/core/Hooks.php */ +/* Location: ./system/core/Hooks.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From c4d979c45297ecc021e385a96dc3bae04a4cdbc4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:53:00 +0300 Subject: Switch private methods to protected and cleanup the Ftp library --- system/libraries/Ftp.php | 109 ++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 68 deletions(-) (limited to 'system') diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 4d96c00cc..8aa1650d2 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * FTP Class * @@ -42,16 +40,11 @@ class CI_FTP { public $username = ''; public $password = ''; public $port = 21; - public $passive = TRUE; + public $passive = TRUE; public $debug = FALSE; - public $conn_id = FALSE; + public $conn_id = FALSE; - /** - * Constructor - Sets Preferences - * - * The constructor can be passed an array of config values - */ public function __construct($config = array()) { if (count($config) > 0) @@ -59,7 +52,7 @@ class CI_FTP { $this->initialize($config); } - log_message('debug', "FTP Class Initialized"); + log_message('debug', 'FTP Class Initialized'); } // -------------------------------------------------------------------- @@ -67,7 +60,6 @@ class CI_FTP { /** * Initialize preferences * - * @access public * @param array * @return void */ @@ -90,7 +82,6 @@ class CI_FTP { /** * FTP Connect * - * @access public * @param array the connection values * @return bool */ @@ -133,10 +124,9 @@ class CI_FTP { /** * FTP Login * - * @access private * @return bool */ - private function _login() + protected function _login() { return @ftp_login($this->conn_id, $this->username, $this->password); } @@ -146,10 +136,9 @@ class CI_FTP { /** * Validates the connection ID * - * @access private * @return bool */ - private function _is_conn() + protected function _is_conn() { if ( ! is_resource($this->conn_id)) { @@ -164,17 +153,15 @@ class CI_FTP { // -------------------------------------------------------------------- - /** * Change directory * * The second parameter lets us momentarily turn off debugging so that * this function can be used to test for the existence of a folder - * without throwing an error. There's no FTP equivalent to is_dir() + * without throwing an error. There's no FTP equivalent to is_dir() * so we do it by trying to change to a particular directory. * Internally, this parameter is only used by the "mirror" function below. * - * @access public * @param string * @param bool * @return bool @@ -190,7 +177,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE AND $supress_debug == FALSE) + if ($this->debug == TRUE && $supress_debug == FALSE) { $this->_error('ftp_unable_to_changedir'); } @@ -205,8 +192,8 @@ class CI_FTP { /** * Create a directory * - * @access public * @param string + * @param int * @return bool */ public function mkdir($path = '', $permissions = NULL) @@ -230,7 +217,7 @@ class CI_FTP { // Set file permissions if needed if ( ! is_null($permissions)) { - $this->chmod($path, (int)$permissions); + $this->chmod($path, (int) $permissions); } return TRUE; @@ -241,10 +228,10 @@ class CI_FTP { /** * Upload a file to the server * - * @access public * @param string * @param string * @param string + * @param int * @return bool */ public function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL) @@ -284,7 +271,7 @@ class CI_FTP { // Set file permissions if needed if ( ! is_null($permissions)) { - $this->chmod($rempath, (int)$permissions); + $this->chmod($rempath, (int) $permissions); } return TRUE; @@ -295,7 +282,6 @@ class CI_FTP { /** * Download a file from a remote server to the local server * - * @access public * @param string * @param string * @param string @@ -337,7 +323,6 @@ class CI_FTP { /** * Rename (or move) a file * - * @access public * @param string * @param string * @param bool @@ -369,7 +354,6 @@ class CI_FTP { /** * Move a file * - * @access public * @param string * @param string * @return bool @@ -384,7 +368,6 @@ class CI_FTP { /** * Rename (or move) a file * - * @access public * @param string * @return bool */ @@ -415,7 +398,6 @@ class CI_FTP { * Delete a folder and recursively delete everything (including sub-folders) * containted within it. * - * @access public * @param string * @return bool */ @@ -427,11 +409,11 @@ class CI_FTP { } // Add a trailing slash to the file path if needed - $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath); + $filepath = preg_replace('/(.+?)\/*$/', '\\1/', $filepath); $list = $this->list_files($filepath); - if ($list !== FALSE AND count($list) > 0) + if ($list !== FALSE && count($list) > 0) { foreach ($list as $item) { @@ -463,7 +445,6 @@ class CI_FTP { /** * Set file permissions * - * @access public * @param string the file path * @param string the permissions * @return bool @@ -494,7 +475,6 @@ class CI_FTP { /** * FTP List files in the specified directory * - * @access public * @return array */ public function list_files($path = '.') @@ -512,11 +492,11 @@ class CI_FTP { /** * Read a directory and recreate it remotely * - * This function recursively reads a folder and everything it contains (including - * sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure - * of the original file path will be recreated on the server. + * This function recursively reads a folder and everything it contains + * (including sub-folders) and creates a mirror via FTP based on it. + * Whatever the directory structure of the original file path will be + * recreated on the server. * - * @access public * @param string path to source with trailing slash * @param string path to destination - include the base folder with trailing slash * @return bool @@ -532,7 +512,7 @@ class CI_FTP { if ($fp = @opendir($locpath)) { // Attempt to open the remote file path and try to create it, if it doesn't exist - if ( ! $this->changedir($rempath, TRUE) AND ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))) + if ( ! $this->changedir($rempath, TRUE) && ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))) { return FALSE; } @@ -542,9 +522,9 @@ class CI_FTP { { if (@is_dir($locpath.$file) && $file[0] !== '.') { - $this->mirror($locpath.$file."/", $rempath.$file."/"); + $this->mirror($locpath.$file.'/', $rempath.$file.'/'); } - elseif ($file[0] !== ".") + elseif ($file[0] !== '.') { // Get the file extension so we can se the upload type $ext = $this->_getext($file); @@ -565,11 +545,10 @@ class CI_FTP { /** * Extract the file extension * - * @access private * @param string * @return string */ - private function _getext($filename) + protected function _getext($filename) { if (FALSE === strpos($filename, '.')) { @@ -580,36 +559,34 @@ class CI_FTP { return end($x); } - // -------------------------------------------------------------------- /** * Set the upload type * - * @access private * @param string * @return string */ - private function _settype($ext) + protected function _settype($ext) { $text_types = array( - 'txt', - 'text', - 'php', - 'phps', - 'php4', - 'js', - 'css', - 'htm', - 'html', - 'phtml', - 'shtml', - 'log', - 'xml' - ); - - - return (in_array($ext, $text_types)) ? 'ascii' : 'binary'; + 'txt', + 'text', + 'php', + 'phps', + 'php4', + 'js', + 'css', + 'htm', + 'html', + 'phtml', + 'shtml', + 'log', + 'xml' + ); + + + return in_array($ext, $text_types) ? 'ascii' : 'binary'; } // ------------------------------------------------------------------------ @@ -617,7 +594,6 @@ class CI_FTP { /** * Close the connection * - * @access public * @return bool */ public function close() @@ -635,20 +611,17 @@ class CI_FTP { /** * Display error message * - * @access private * @param string * @return void */ - private function _error($line) + protected function _error($line) { $CI =& get_instance(); $CI->lang->load('ftp'); show_error($CI->lang->line($line)); } - } -// END FTP Class /* End of file Ftp.php */ -/* Location: ./system/libraries/Ftp.php */ +/* Location: ./system/libraries/Ftp.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6f042ccc261645530e897bb8c390eae0640bacb0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:58:33 +0300 Subject: Switch private methods and properties to protected and cleanup the Cart library --- system/libraries/Cart.php | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 60a1e52fe..305960f5f 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Shopping Cart Class * @@ -41,12 +39,11 @@ class CI_Cart { // These are the regular expression rules that we use to validate the product ID and product name public $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods public $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods - public $product_name_safe = true; // only allow safe product names - - // Private variables. Do not change! - private $CI; - private $_cart_contents = array(); + public $product_name_safe = TRUE; // only allow safe product names + // Protected variables. Do not change! + protected $CI; + protected $_cart_contents = array(); /** * Shopping Class Constructor @@ -72,7 +69,7 @@ class CI_Cart { $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0); } - log_message('debug', "Cart Class Initialized"); + log_message('debug', 'Cart Class Initialized'); } // -------------------------------------------------------------------- @@ -80,7 +77,6 @@ class CI_Cart { /** * Insert items into the cart and save it to the session table * - * @access public * @param array * @return bool */ @@ -110,7 +106,7 @@ class CI_Cart { { foreach ($items as $val) { - if (is_array($val) AND isset($val['id'])) + if (is_array($val) && isset($val['id'])) { if ($this->_insert($val)) { @@ -135,7 +131,6 @@ class CI_Cart { /** * Insert * - * @access private * @param array * @return bool */ @@ -213,7 +208,7 @@ class CI_Cart { // Internally, we need to treat identical submissions, but with different options, as a unique product. // Our solution is to convert the options array to a string and MD5 it along with the product ID. // This becomes the unique "row ID" - if (isset($items['options']) AND count($items['options']) > 0) + if (isset($items['options']) && count($items['options']) > 0) { $rowid = md5($items['id'].implode('', $items['options'])); } @@ -249,7 +244,6 @@ class CI_Cart { * changes to the quantity before checkout. That array must contain the * product ID and quantity for each item. * - * @access public * @param array * @param string * @return bool @@ -308,11 +302,10 @@ class CI_Cart { * changes to the quantity before checkout. That array must contain the * product ID and quantity for each item. * - * @access private * @param array * @return bool */ - private function _update($items = array()) + protected function _update($items = array()) { // Without these array indexes there is nothing we can do if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']])) @@ -348,10 +341,9 @@ class CI_Cart { /** * Save the cart array to the session DB * - * @access private * @return bool */ - private function _save_cart() + protected function _save_cart() { // Lets add up the individual prices and set the cart sub-total $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0; @@ -390,8 +382,7 @@ class CI_Cart { /** * Cart Total * - * @access public - * @return integer + * @return int */ public function total() { @@ -405,8 +396,7 @@ class CI_Cart { * * Removes an item from the cart * - * @access public - * @return boolean + * @return bool */ public function remove($rowid) { @@ -423,8 +413,7 @@ class CI_Cart { * * Returns the total item count * - * @access public - * @return integer + * @return int */ public function total_items() { @@ -438,7 +427,6 @@ class CI_Cart { * * Returns the entire cart array * - * @access public * @return array */ public function contents($newest_first = FALSE) @@ -461,7 +449,6 @@ class CI_Cart { * Returns TRUE if the rowid passed to this function correlates to an item * that has options associated with it. * - * @access public * @return bool */ public function has_options($rowid = '') @@ -476,7 +463,7 @@ class CI_Cart { * * Returns the an array of options, for a particular product row ID * - * @access public + * @param int * @return array */ public function product_options($rowid = '') @@ -491,7 +478,7 @@ class CI_Cart { * * Returns the supplied number with commas and a decimal point. * - * @access public + * @param float * @return string */ public function format_number($n = '') @@ -514,7 +501,6 @@ class CI_Cart { * * Empties the cart and kills the session * - * @access public * @return void */ public function destroy() @@ -523,9 +509,7 @@ class CI_Cart { $this->CI->session->unset_userdata('cart_contents'); } - } -// END Cart Class /* End of file Cart.php */ -/* Location: ./system/libraries/Cart.php */ +/* Location: ./system/libraries/Cart.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 74476e1c4371bb7dc8c9727898026687d875284f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:03:40 +0300 Subject: Switch private methods and properties to protected and cleanup the Parser library --- system/libraries/Cart.php | 2 +- system/libraries/Parser.php | 47 ++++++++++++++++----------------------------- 2 files changed, 18 insertions(+), 31 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 305960f5f..ca7be555e 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -134,7 +134,7 @@ class CI_Cart { * @param array * @return bool */ - private function _insert($items = array()) + protected function _insert($items = array()) { // Was any cart data passed? No? Bah... if ( ! is_array($items) OR count($items) === 0) diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 290e17fc0..d1b5b764b 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Parser Class * @@ -41,15 +39,14 @@ class CI_Parser { public $l_delim = '{'; public $r_delim = '}'; public $object; - private $CI; + protected $CI; /** - * Parse a template + * Parse a template * * Parses pseudo-variables contained in the specified template view, * replacing them with the data in the second param * - * @access public * @param string * @param array * @param bool @@ -66,12 +63,11 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a String + * Parse a String * * Parses pseudo-variables contained in the specified string, * replacing them with the data in the second param * - * @access public * @param string * @param array * @param bool @@ -85,18 +81,17 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a template + * Parse a template * * Parses pseudo-variables contained in the specified template, * replacing them with the data in the second param * - * @access private * @param string * @param array * @param bool * @return string */ - private function _parse($template, $data, $return = FALSE) + protected function _parse($template, $data, $return = FALSE) { if ($template == '') { @@ -126,9 +121,8 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Set the left/right variable delimiters + * Set the left/right variable delimiters * - * @access public * @param string * @param string * @return void @@ -142,15 +136,14 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a single key/value + * Parse a single key/value * - * @access private * @param string * @param string * @param string * @return string */ - private function _parse_single($key, $val, $string) + protected function _parse_single($key, $val, $string) { return str_replace($this->l_delim.$key.$this->r_delim, (string) $val, $string); } @@ -158,17 +151,16 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a tag pair + * Parse a tag pair * - * Parses tag pairs: {some_tag} string... {/some_tag} + * Parses tag pairs: {some_tag} string... {/some_tag} * - * @access private * @param string * @param array * @param string * @return string */ - private function _parse_pair($variable, $data, $string) + protected function _parse_pair($variable, $data, $string) { if (FALSE === ($match = $this->_match_pair($string, $variable))) { @@ -200,25 +192,20 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Matches a variable pair + * Matches a variable pair * - * @access private * @param string * @param string * @return mixed */ - private function _match_pair($string, $variable) + protected function _match_pair($string, $variable) { - if ( ! preg_match("|" . preg_quote($this->l_delim) . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . '/' . $variable . preg_quote($this->r_delim) . "|s", $string, $match)) - { - return FALSE; - } - - return $match; + return preg_match('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s', + $string, $match) + ? $match : FALSE; } } -// END Parser Class /* End of file Parser.php */ -/* Location: ./system/libraries/Parser.php */ +/* Location: ./system/libraries/Parser.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b24b033a9c285c98802fbd7bf16d486e355e2f97 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:34:39 +0300 Subject: Switch private methods and properties to protected and cleanup the Cache library and drivers --- system/libraries/Cache/Cache.php | 109 +++++++++------------ system/libraries/Cache/drivers/Cache_apc.php | 43 ++++---- system/libraries/Cache/drivers/Cache_dummy.php | 37 +++---- system/libraries/Cache/drivers/Cache_file.php | 42 ++++---- system/libraries/Cache/drivers/Cache_memcached.php | 57 +++++------ system/libraries/Cache/drivers/Cache_wincache.php | 7 +- 6 files changed, 125 insertions(+), 170 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 7642a5270..f98241617 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Caching Class * @@ -50,11 +48,37 @@ class CI_Cache extends CI_Driver_Library { protected $_adapter = 'dummy'; protected $_backup_driver; + /** + * Constructor + * + * Initialize class properties based on the configuration array. + * + * @param array + * @return void + */ public function __construct($config = array()) { - if ( ! empty($config)) + $default_config = array( + 'adapter', + 'memcached' + ); + + foreach ($default_config as $key) { - $this->_initialize($config); + if (isset($config[$key])) + { + $param = '_'.$key; + + $this->{$param} = $config[$key]; + } + } + + if (isset($config['backup'])) + { + if (in_array('cache_'.$config['backup'], $this->valid_drivers)) + { + $this->_backup_driver = $config['backup']; + } } } @@ -63,11 +87,11 @@ class CI_Cache extends CI_Driver_Library { /** * Get * - * Look for a value in the cache. If it exists, return the data + * Look for a value in the cache. If it exists, return the data * if not, return FALSE * - * @param string - * @return mixed value that is stored/FALSE on failure + * @param string + * @return mixed value that is stored/FALSE on failure */ public function get($id) { @@ -79,11 +103,10 @@ class CI_Cache extends CI_Driver_Library { /** * Cache Save * - * @param string Unique Key - * @param mixed Data to store - * @param int Length of time (in seconds) to cache the data - * - * @return boolean true on success/false on failure + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -95,8 +118,8 @@ class CI_Cache extends CI_Driver_Library { /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @return boolean true on success/false on failure + * @param mixed unique identifier of the item in the cache + * @return bool true on success/false on failure */ public function delete($id) { @@ -108,7 +131,7 @@ class CI_Cache extends CI_Driver_Library { /** * Clean the cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -120,8 +143,8 @@ class CI_Cache extends CI_Driver_Library { /** * Cache Info * - * @param string user/filehits - * @return mixed array on success, false on failure + * @param string user/filehits + * @return mixed array on success, false on failure */ public function cache_info($type = 'user') { @@ -133,8 +156,8 @@ class CI_Cache extends CI_Driver_Library { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed return value from child method + * @param mixed key to get cache metadata on + * @return mixed return value from child method */ public function get_metadata($id) { @@ -143,47 +166,11 @@ class CI_Cache extends CI_Driver_Library { // ------------------------------------------------------------------------ - /** - * Initialize - * - * Initialize class properties based on the configuration array. - * - * @param array - * @return void - */ - private function _initialize($config) - { - $default_config = array( - 'adapter', - 'memcached' - ); - - foreach ($default_config as $key) - { - if (isset($config[$key])) - { - $param = '_'.$key; - - $this->{$param} = $config[$key]; - } - } - - if (isset($config['backup'])) - { - if (in_array('cache_'.$config['backup'], $this->valid_drivers)) - { - $this->_backup_driver = $config['backup']; - } - } - } - - // ------------------------------------------------------------------------ - /** * Is the requested driver supported in this environment? * - * @param string The driver to test. - * @return array + * @param string The driver to test. + * @return array */ public function is_supported($driver) { @@ -202,8 +189,8 @@ class CI_Cache extends CI_Driver_Library { /** * __get() * - * @param child - * @return object + * @param child + * @return object */ public function __get($child) { @@ -217,9 +204,7 @@ class CI_Cache extends CI_Driver_Library { return $obj; } - // ------------------------------------------------------------------------ } -// End Class /* End of file Cache.php */ -/* Location: ./system/libraries/Cache/Cache.php */ +/* Location: ./system/libraries/Cache/Cache.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index c387a30fc..59ab67533 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter APC Caching Class * @@ -36,23 +34,22 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_apc extends CI_Driver { /** * Get * - * Look for a value in the cache. If it exists, return the data + * Look for a value in the cache. If it exists, return the data * if not, return FALSE * - * @param string - * @return mixed value that is stored/FALSE on failure + * @param string + * @return mixed value that is stored/FALSE on failure */ public function get($id) { $data = apc_fetch($id); - return (is_array($data)) ? $data[0] : FALSE; + return is_array($data) ? $data[0] : FALSE; } // ------------------------------------------------------------------------ @@ -60,11 +57,11 @@ class CI_Cache_apc extends CI_Driver { /** * Cache Save * - * @param string Unique Key - * @param mixed Data to store - * @param int Length of time (in seconds) to cache the data + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data * - * @return boolean true on success/false on failure + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -77,8 +74,8 @@ class CI_Cache_apc extends CI_Driver { /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @param boolean true on success/false on failure + * @param mixed unique identifier of the item in the cache + * @param bool true on success/false on failure */ public function delete($id) { @@ -90,7 +87,7 @@ class CI_Cache_apc extends CI_Driver { /** * Clean the cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -102,8 +99,8 @@ class CI_Cache_apc extends CI_Driver { /** * Cache Info * - * @param string user/filehits - * @return mixed array on success, false on failure + * @param string user/filehits + * @return mixed array on success, false on failure */ public function cache_info($type = NULL) { @@ -115,8 +112,8 @@ class CI_Cache_apc extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed array on success/false on failure + * @param mixed key to get cache metadata on + * @return mixed array on success/false on failure */ public function get_metadata($id) { @@ -142,10 +139,12 @@ class CI_Cache_apc extends CI_Driver { * is_supported() * * Check to see if APC is available on this system, bail if it isn't. + * + * @return bool */ public function is_supported() { - if ( ! extension_loaded('apc') OR ini_get('apc.enabled') != "1") + if ( ! extension_loaded('apc') OR ! (bool) @ini_get('apc.enabled')) { log_message('error', 'The APC PHP extension must be loaded to use APC Cache.'); return FALSE; @@ -154,11 +153,7 @@ class CI_Cache_apc extends CI_Driver { return TRUE; } - // ------------------------------------------------------------------------ - - } -// End Class /* End of file Cache_apc.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index c9767e401..e8b791c5b 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Dummy Caching Class * @@ -36,7 +34,6 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_dummy extends CI_Driver { /** @@ -44,8 +41,8 @@ class CI_Cache_dummy extends CI_Driver { * * Since this is the dummy class, it's always going to return FALSE. * - * @param string - * @return Boolean FALSE + * @param string + * @return bool FALSE */ public function get($id) { @@ -57,11 +54,10 @@ class CI_Cache_dummy extends CI_Driver { /** * Cache Save * - * @param string Unique Key - * @param mixed Data to store - * @param int Length of time (in seconds) to cache the data - * - * @return boolean TRUE, Simulating success + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * @return bool TRUE, Simulating success */ public function save($id, $data, $ttl = 60) { @@ -73,8 +69,8 @@ class CI_Cache_dummy extends CI_Driver { /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @param boolean TRUE, simulating success + * @param mixed unique identifier of the item in the cache + * @param bool TRUE, simulating success */ public function delete($id) { @@ -86,7 +82,7 @@ class CI_Cache_dummy extends CI_Driver { /** * Clean the cache * - * @return boolean TRUE, simulating success + * @return bool TRUE, simulating success */ public function clean() { @@ -98,8 +94,8 @@ class CI_Cache_dummy extends CI_Driver { /** * Cache Info * - * @param string user/filehits - * @return boolean FALSE + * @param string user/filehits + * @return bool FALSE */ public function cache_info($type = NULL) { @@ -111,8 +107,8 @@ class CI_Cache_dummy extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return boolean FALSE + * @param mixed key to get cache metadata on + * @return bool FALSE */ public function get_metadata($id) { @@ -125,17 +121,14 @@ class CI_Cache_dummy extends CI_Driver { * Is this caching driver supported on the system? * Of course this one is. * - * @return TRUE; + * @return bool TRUE */ public function is_supported() { return TRUE; } - // ------------------------------------------------------------------------ - } -// End Class /* End of file Cache_dummy.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index c0be0def4..dd27aa90e 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Memcached Caching Class * @@ -36,14 +34,10 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_file extends CI_Driver { protected $_cache_path; - /** - * Constructor - */ public function __construct() { $CI =& get_instance(); @@ -57,8 +51,8 @@ class CI_Cache_file extends CI_Driver { /** * Fetch from cache * - * @param mixed unique key id - * @return mixed data on success/false on failure + * @param mixed unique key id + * @return mixed data on success/false on failure */ public function get($id) { @@ -83,11 +77,11 @@ class CI_Cache_file extends CI_Driver { /** * Save into cache * - * @param string unique key - * @param mixed data to store - * @param int length of time (in seconds) the cache is valid - * - Default is 60 seconds - * @return boolean true on success/false on failure + * @param string unique key + * @param mixed data to store + * @param int length of time (in seconds) the cache is valid + * - Default is 60 seconds + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -111,12 +105,12 @@ class CI_Cache_file extends CI_Driver { /** * Delete from Cache * - * @param mixed unique identifier of item in cache - * @return boolean true on success/false on failure + * @param mixed unique identifier of item in cache + * @return bool true on success/false on failure */ public function delete($id) { - return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE; + return file_exists($this->_cache_path.$id) ? unlink($this->_cache_path.$id) : FALSE; } // ------------------------------------------------------------------------ @@ -124,7 +118,7 @@ class CI_Cache_file extends CI_Driver { /** * Clean the Cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -138,8 +132,8 @@ class CI_Cache_file extends CI_Driver { * * Not supported by file-based caching * - * @param string user/filehits - * @return mixed FALSE + * @param string user/filehits + * @return mixed FALSE */ public function cache_info($type = NULL) { @@ -151,8 +145,8 @@ class CI_Cache_file extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed FALSE on failure, array on success. + * @param mixed key to get cache metadata on + * @return mixed FALSE on failure, array on success. */ public function get_metadata($id) { @@ -188,16 +182,14 @@ class CI_Cache_file extends CI_Driver { * * In the file driver, check to see that the cache directory is indeed writable * - * @return boolean + * @return bool */ public function is_supported() { return is_really_writable($this->_cache_path); } - // ------------------------------------------------------------------------ } -// End Class /* End of file Cache_file.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index b8f2d7e4c..1028c8fd5 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Memcached Caching Class * @@ -36,12 +34,11 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_memcached extends CI_Driver { - private $_memcached; // Holds the memcached object + protected $_memcached; // Holds the memcached object - protected $_memcache_conf = array( + protected $_memcache_conf = array( 'default' => array( 'default_host' => '127.0.0.1', 'default_port' => 11211, @@ -49,19 +46,17 @@ class CI_Cache_memcached extends CI_Driver { ) ); - // ------------------------------------------------------------------------ - /** * Fetch from cache * - * @param mixed unique key id - * @return mixed data on success/false on failure + * @param mixed unique key id + * @return mixed data on success/false on failure */ public function get($id) { $data = $this->_memcached->get($id); - return (is_array($data)) ? $data[0] : FALSE; + return is_array($data) ? $data[0] : FALSE; } // ------------------------------------------------------------------------ @@ -69,18 +64,18 @@ class CI_Cache_memcached extends CI_Driver { /** * Save * - * @param string unique identifier - * @param mixed data being cached - * @param int time to live - * @return boolean true on success, false on failure + * @param string unique identifier + * @param mixed data being cached + * @param int time to live + * @return bool true on success, false on failure */ public function save($id, $data, $ttl = 60) { - if (get_class($this->_memcached) == 'Memcached') + if (get_class($this->_memcached) === 'Memcached') { return $this->_memcached->set($id, array($data, time(), $ttl), $ttl); } - else if (get_class($this->_memcached) == 'Memcache') + elseif (get_class($this->_memcached) === 'Memcache') { return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl); } @@ -93,8 +88,8 @@ class CI_Cache_memcached extends CI_Driver { /** * Delete from Cache * - * @param mixed key to be deleted. - * @return boolean true on success, false on failure + * @param mixed key to be deleted. + * @return bool true on success, false on failure */ public function delete($id) { @@ -106,7 +101,7 @@ class CI_Cache_memcached extends CI_Driver { /** * Clean the Cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -118,10 +113,9 @@ class CI_Cache_memcached extends CI_Driver { /** * Cache Info * - * @param null type not supported in memcached - * @return mixed array on success, false on failure + * @return mixed array on success, false on failure */ - public function cache_info($type = NULL) + public function cache_info() { return $this->_memcached->getStats(); } @@ -131,8 +125,8 @@ class CI_Cache_memcached extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed FALSE on failure, array on success. + * @param mixed key to get cache metadata on + * @return mixed FALSE on failure, array on success. */ public function get_metadata($id) { @@ -156,8 +150,10 @@ class CI_Cache_memcached extends CI_Driver { /** * Setup memcached. + * + * @return bool */ - private function _setup_memcached() + protected function _setup_memcached() { // Try to load memcached server info from the config file. $CI =& get_instance(); @@ -179,14 +175,13 @@ class CI_Cache_memcached extends CI_Driver { { $this->_memcached = new Memcached(); } - else if (class_exists('Memcache')) + elseif (class_exists('Memcache')) { $this->_memcached = new Memcache(); } else { log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); - return FALSE; } @@ -237,23 +232,21 @@ class CI_Cache_memcached extends CI_Driver { * * Returns FALSE if memcached is not supported on the system. * If it is, we setup the memcached object & return TRUE + * + * @return bool */ public function is_supported() { if ( ! extension_loaded('memcached') && ! extension_loaded('memcache')) { log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); - return FALSE; } return $this->_setup_memcached(); } - // ------------------------------------------------------------------------ - } -// End Class /* End of file Cache_memcached.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index df619d4e6..b32e66a46 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Wincache Caching Class * @@ -39,7 +37,6 @@ * @author Mike Murkovic * @link */ - class CI_Cache_wincache extends CI_Driver { /** @@ -68,7 +65,7 @@ class CI_Cache_wincache extends CI_Driver { * @param string Unique Key * @param mixed Data to store * @param int Length of time (in seconds) to cache the data - * @return bool true on success/false on failure + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -162,4 +159,4 @@ class CI_Cache_wincache extends CI_Driver { } /* End of file Cache_wincache.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6dbabb565e1411a2c62fa86d46b0b2bbb98ab9b0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:41:48 +0300 Subject: Switch a private property to protected and cleanup the Calendar library --- system/libraries/Calendar.php | 61 ++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) (limited to 'system') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 6c04de8a2..b6f145d95 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Calendar Class * @@ -40,7 +38,7 @@ */ class CI_Calendar { - private $CI; + protected $CI; public $lang; public $local_time; public $template = ''; @@ -54,6 +52,9 @@ class CI_Calendar { * Constructor * * Loads the calendar language file and sets the default time reference + * + * @param array + * @return void */ public function __construct($config = array()) { @@ -71,7 +72,7 @@ class CI_Calendar { $this->initialize($config); } - log_message('debug', "Calendar Class Initialized"); + log_message('debug', 'Calendar Class Initialized'); } // -------------------------------------------------------------------- @@ -81,7 +82,6 @@ class CI_Calendar { * * Accepts an associative array as input, containing display preferences * - * @access public * @param array config preferences * @return void */ @@ -101,9 +101,8 @@ class CI_Calendar { /** * Generate the calendar * - * @access public - * @param integer the year - * @param integer the month + * @param int the year + * @param int the month * @param array the data to be shown in the calendar cells * @return string */ @@ -147,7 +146,7 @@ class CI_Calendar { // Set the starting day number $local_date = mktime(12, 0, 0, $month, 1, $year); $date = getdate($local_date); - $day = $start_day + 1 - $date["wday"]; + $day = $start_day + 1 - $date['wday']; while ($day > 1) { @@ -160,7 +159,7 @@ class CI_Calendar { $cur_month = date('m', $this->local_time); $cur_day = date('j', $this->local_time); - $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE; + $is_current_month = ($cur_year == $year && $cur_month == $month); // Generate the template data array $this->parse_template(); @@ -172,7 +171,7 @@ class CI_Calendar { if ($this->show_next_prev == TRUE) { // Add a trailing slash to the URL if needed - $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url); + $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; @@ -213,21 +212,21 @@ class CI_Calendar { for ($i = 0; $i < 7; $i++) { - $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; - if ($day > 0 AND $day <= $total_days) + if ($day > 0 && $day <= $total_days) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } @@ -238,7 +237,7 @@ class CI_Calendar { $out .= $this->temp['cal_cell_blank']; } - $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; $day++; } @@ -258,8 +257,7 @@ class CI_Calendar { * Generates a textual month name based on the numeric * month provided. * - * @access public - * @param integer the month + * @param int the month * @return string */ public function get_month_name($month) @@ -289,9 +287,8 @@ class CI_Calendar { * Get Day Names * * Returns an array of day names (Sunday, Monday, etc.) based - * on the type. Options: long, short, abrev + * on the type. Options: long, short, abrev * - * @access public * @param string * @return array */ @@ -333,9 +330,8 @@ class CI_Calendar { * For example, if you submit 13 as the month, the year will * increment and the month will become January. * - * @access public - * @param integer the month - * @param integer the year + * @param int the month + * @param int the year * @return array */ public function adjust_date($month, $year) @@ -370,10 +366,9 @@ class CI_Calendar { /** * Total days in a given month * - * @access public - * @param integer the month - * @param integer the year - * @return integer + * @param int the month + * @param int the year + * @return int */ public function get_total_days($month, $year) { @@ -387,7 +382,7 @@ class CI_Calendar { // Is the year a leap year? if ($month == 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0)) + if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) { return 29; } @@ -403,8 +398,7 @@ class CI_Calendar { * * This is used in the event that the user has not created their own template * - * @access public - * @return array + * @return array */ public function default_template() { @@ -441,7 +435,6 @@ class CI_Calendar { * Harvests the data within the template {pseudo-variables} * used to display the calendar * - * @access public * @return void */ public function parse_template() @@ -457,7 +450,7 @@ class CI_Calendar { foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val) { - if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match)) + if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match)) { $this->temp[$val] = $match[1]; } @@ -470,7 +463,5 @@ class CI_Calendar { } -// END CI_Calendar class - /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */ +/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From bb30d79ef0a7d2a3949c479783ab2a1390118836 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:49:09 +0300 Subject: Remove access description lines and fix comments in system/core/Common.php --- system/core/Common.php | 190 +++++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 94 deletions(-) (limited to 'system') diff --git a/system/core/Common.php b/system/core/Common.php index f20acafd4..aeb784bbe 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Common Functions * @@ -42,15 +40,14 @@ // ------------------------------------------------------------------------ /** -* Determines if the current version of PHP is greater then the supplied value -* -* Since there are a few places where we conditionally test for PHP > 5 -* we'll set a static variable. -* -* @access public -* @param string -* @return bool TRUE if the current version is $version or higher -*/ + * Determines if the current version of PHP is greater then the supplied value + * + * Since there are a few places where we conditionally test for PHP > 5 + * we'll set a static variable. + * + * @param string + * @return bool TRUE if the current version is $version or higher + */ if ( ! function_exists('is_php')) { function is_php($version = '5.0.0') @@ -76,7 +73,7 @@ if ( ! function_exists('is_php')) * the file, based on the read-only attribute. is_writable() is also unreliable * on Unix servers if safe_mode is on. * - * @access public + * @param string * @return void */ if ( ! function_exists('is_really_writable')) @@ -118,18 +115,17 @@ if ( ! function_exists('is_really_writable')) // ------------------------------------------------------------------------ /** -* Class registry -* -* This function acts as a singleton. If the requested class does not -* exist it is instantiated and set to a static variable. If it has -* previously been instantiated the variable is returned. -* -* @access public -* @param string the class name being requested -* @param string the directory where the class should be found -* @param string the class name prefix -* @return object -*/ + * Class registry + * + * This function acts as a singleton. If the requested class does not + * exist it is instantiated and set to a static variable. If it has + * previously been instantiated the variable is returned. + * + * @param string the class name being requested + * @param string the directory where the class should be found + * @param string the class name prefix + * @return object + */ if ( ! function_exists('load_class')) { function &load_class($class, $directory = 'libraries', $prefix = 'CI_') @@ -192,12 +188,12 @@ if ( ! function_exists('load_class')) // -------------------------------------------------------------------- /** -* Keeps track of which libraries have been loaded. This function is -* called by the load_class() function above -* -* @access public -* @return array -*/ + * Keeps track of which libraries have been loaded. This function is + * called by the load_class() function above + * + * @param string + * @return array + */ if ( ! function_exists('is_loaded')) { function &is_loaded($class = '') @@ -216,14 +212,14 @@ if ( ! function_exists('is_loaded')) // ------------------------------------------------------------------------ /** -* Loads the main config.php file -* -* This function lets us grab the config file even if the Config class -* hasn't been instantiated yet -* -* @access private -* @return array -*/ + * Loads the main config.php file + * + * This function lets us grab the config file even if the Config class + * hasn't been instantiated yet + * + * @param array + * @return array + */ if ( ! function_exists('get_config')) { function &get_config($replace = array()) @@ -276,11 +272,11 @@ if ( ! function_exists('get_config')) // ------------------------------------------------------------------------ /** -* Returns the specified config item -* -* @access public -* @return mixed -*/ + * Returns the specified config item + * + * @param string + * @return mixed + */ if ( ! function_exists('config_item')) { function config_item($item) @@ -305,17 +301,19 @@ if ( ! function_exists('config_item')) // ------------------------------------------------------------------------ /** -* Error Handler -* -* This function lets us invoke the exception class and -* display errors using the standard error template located -* in application/errors/errors.php -* This function will send the error page directly to the -* browser and exit. -* -* @access public -* @return void -*/ + * Error Handler + * + * This function lets us invoke the exception class and + * display errors using the standard error template located + * in application/errors/errors.php + * This function will send the error page directly to the + * browser and exit. + * + * @param string + * @param int + * @param string + * @return void + */ if ( ! function_exists('show_error')) { function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') @@ -329,15 +327,16 @@ if ( ! function_exists('show_error')) // ------------------------------------------------------------------------ /** -* 404 Page Handler -* -* This function is similar to the show_error() function above -* However, instead of the standard error template it displays -* 404 errors. -* -* @access public -* @return void -*/ + * 404 Page Handler + * + * This function is similar to the show_error() function above + * However, instead of the standard error template it displays + * 404 errors. + * + * @param string + * @param bool + * @return void + */ if ( ! function_exists('show_404')) { function show_404($page = '', $log_error = TRUE) @@ -351,14 +350,16 @@ if ( ! function_exists('show_404')) // ------------------------------------------------------------------------ /** -* Error Logging Interface -* -* We use this as a simple mechanism to access the logging -* class and send messages to be logged. -* -* @access public -* @return void -*/ + * Error Logging Interface + * + * We use this as a simple mechanism to access the logging + * class and send messages to be logged. + * + * @param string + * @param string + * @param bool + * @return void + */ if ( ! function_exists('log_message')) { function log_message($level = 'error', $message, $php_error = FALSE) @@ -380,8 +381,7 @@ if ( ! function_exists('log_message')) /** * Set HTTP Status Header * - * @access public - * @param int the status code + * @param int the status code * @param string * @return void */ @@ -467,19 +467,22 @@ if ( ! function_exists('set_status_header')) // -------------------------------------------------------------------- /** -* Exception Handler -* -* This is the custom exception handler that is declaired at the top -* of Codeigniter.php. The main reason we use this is to permit -* PHP errors to be logged in our own log files since the user may -* not have access to server logs. Since this function -* effectively intercepts PHP errors, however, we also need -* to display errors based on the current error_reporting level. -* We do that with the use of a PHP error template. -* -* @access private -* @return void -*/ + * Exception Handler + * + * This is the custom exception handler that is declaired at the top + * of Codeigniter.php. The main reason we use this is to permit + * PHP errors to be logged in our own log files since the user may + * not have access to server logs. Since this function + * effectively intercepts PHP errors, however, we also need + * to display errors based on the current error_reporting level. + * We do that with the use of a PHP error template. + * + * @param int + * @param string + * @param string + * @param int + * @return void + */ if ( ! function_exists('_exception_handler')) { function _exception_handler($severity, $message, $filepath, $line) @@ -521,8 +524,8 @@ if ( ! function_exists('_exception_handler')) * This prevents sandwiching null characters * between ascii characters, like Java\0script. * - * @access public * @param string + * @param bool * @return string */ if ( ! function_exists('remove_invisible_characters')) @@ -554,12 +557,11 @@ if ( ! function_exists('remove_invisible_characters')) // ------------------------------------------------------------------------ /** -* Returns HTML escaped variable -* -* @access public -* @param mixed -* @return mixed -*/ + * Returns HTML escaped variable + * + * @param mixed + * @return mixed + */ if ( ! function_exists('html_escape')) { function html_escape($var) @@ -571,4 +573,4 @@ if ( ! function_exists('html_escape')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From a8bb4be3b2aa5984c465bbcf1ef51fd3eba92208 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:54:23 +0300 Subject: Remove remaining access description lines from database classes and styleguide example --- system/database/DB_active_rec.php | 40 +++++++++--------------- system/database/drivers/mysqli/mysqli_driver.php | 1 - 2 files changed, 15 insertions(+), 26 deletions(-) (limited to 'system') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index fe591dda1..b324226ab 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Active Record Class * @@ -422,7 +420,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { foreach ($key as $k => $v) { - $prefix = (count($this->ar_where) === 0 AND count($this->ar_cache_where) === 0) ? '' : $type; + $prefix = (count($this->ar_where) === 0 && count($this->ar_cache_where) === 0) ? '' : $type; if (is_null($v) && ! $this->_has_operator($k)) { @@ -537,7 +535,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * @param string The field to search * @param array The values searched on - * @param boolean If the statement would be IN or NOT IN + * @param bool If the statement would be IN or NOT IN * @param string * @return object */ @@ -719,7 +717,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { { $type = $this->_group_get_type($type); $this->ar_where_group_started = TRUE; - $prefix = (count($this->ar_where) === 0 AND count($this->ar_cache_where) === 0) ? '' : $type; + $prefix = (count($this->ar_where) === 0 && count($this->ar_cache_where) === 0) ? '' : $type; $this->ar_where[] = $value = $prefix.$not.str_repeat(' ', ++$this->ar_where_group_count).' ('; if ($this->ar_caching) @@ -984,8 +982,8 @@ abstract class CI_DB_active_record extends CI_DB_driver { /** * Sets the LIMIT value * - * @param integer the limit value - * @param integer the offset value + * @param int the limit value + * @param int the offset value * @return object */ public function limit($value, $offset = NULL) @@ -1005,7 +1003,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { /** * Sets the OFFSET value * - * @param integer the offset value + * @param int the offset value * @return object */ public function offset($offset) @@ -1021,7 +1019,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * @param mixed * @param string - * @param boolean + * @param bool * @return object */ public function set($key, $value = '', $escape = TRUE) @@ -1055,9 +1053,8 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Compiles a SELECT query string and returns the sql. * - * @access public * @param string the table name to select from (optional) - * @param boolean TRUE: resets AR values; FALSE: leave AR vaules alone + * @param bool TRUE: resets AR values; FALSE: leave AR vaules alone * @return string */ public function get_compiled_select($table = '', $reset = TRUE) @@ -1226,7 +1223,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * @param mixed * @param string - * @param boolean + * @param bool * @return object */ public function set_insert_batch($key, $value = '', $escape = TRUE) @@ -1283,9 +1280,8 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Compiles an insert query and returns the sql * - * @access public * @param string the table to insert into - * @param boolean TRUE: reset AR values; FALSE: leave AR values alone + * @param bool TRUE: reset AR values; FALSE: leave AR values alone * @return string */ public function get_compiled_insert($table = '', $reset = TRUE) @@ -1316,7 +1312,6 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Compiles an insert string and runs the query * - * @access public * @param string the table to insert data into * @param array an associative array of insert values * @return object @@ -1352,7 +1347,6 @@ abstract class CI_DB_active_record extends CI_DB_driver { * validate that the there data is actually being set and that table * has been chosen to be inserted into. * - * @access public * @param string the table to insert data into * @return string */ @@ -1423,9 +1417,8 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Compiles an update query and returns the sql * - * @access public * @param string the table to update - * @param boolean TRUE: reset AR values; FALSE: leave AR values alone + * @param bool TRUE: reset AR values; FALSE: leave AR values alone * @return string */ public function get_compiled_update($table = '', $reset = TRUE) @@ -1499,7 +1492,6 @@ abstract class CI_DB_active_record extends CI_DB_driver { * validate that data is actually being set and that a table has been * chosen to be update. * - * @access public * @param string the table to update data on * @return bool */ @@ -1584,7 +1576,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * @param array * @param string - * @param boolean + * @param bool * @return object */ public function set_update_batch($key, $index = '', $escape = TRUE) @@ -1696,9 +1688,8 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Compiles a delete query string and returns the sql * - * @access public * @param string the table to delete from - * @param boolean TRUE: reset AR values; FALSE: leave AR values alone + * @param bool TRUE: reset AR values; FALSE: leave AR values alone * @return string */ public function get_compiled_delete($table = '', $reset = TRUE) @@ -1719,7 +1710,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { * @param mixed the table(s) to delete from. String or array * @param mixed the where clause * @param mixed the limit clause - * @param boolean + * @param bool * @return object */ public function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE) @@ -2062,7 +2053,6 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Empties the AR cache * - * @access public * @return void */ public function flush_cache() @@ -2114,7 +2104,7 @@ abstract class CI_DB_active_record extends CI_DB_driver { // If we are "protecting identifiers" we need to examine the "from" // portion of the query to determine if there are any aliases - if ($this->_protect_identifiers === TRUE AND count($this->ar_cache_from) > 0) + if ($this->_protect_identifiers === TRUE && count($this->ar_cache_from) > 0) { $this->_track_aliases($this->ar_from); } diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 4c5d52127..041daf710 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -357,7 +357,6 @@ class CI_DB_mysqli_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param bool * @return string */ -- cgit v1.2.3-24-g4f1b From 5227837eca102b5aa2c14daa4201ffcb0a79f246 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 16:02:30 +0300 Subject: Remove access description lines and cleanup the Xmlrpcs library --- system/libraries/Xmlrpcs.php | 64 ++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 44 deletions(-) (limited to 'system') diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index fc41444bc..6d270c2ea 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -54,10 +54,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc public $controller_obj; public $object = FALSE; - /** - * Constructor - */ - public function __construct($config=array()) + public function __construct($config = array()) { parent::__construct(); $this->set_system_methods(); @@ -67,7 +64,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $this->methods = array_merge($this->methods, $config['functions']); } - log_message('debug', "XML-RPC Server Class Initialized"); + log_message('debug', 'XML-RPC Server Class Initialized'); } // -------------------------------------------------------------------- @@ -75,7 +72,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Initialize Prefs and Serve * - * @access public * @param mixed * @return void */ @@ -107,7 +103,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Setting of System Methods * - * @access public * @return void */ public function set_system_methods() @@ -137,7 +132,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Main Server Function * - * @access public * @return void */ public function serve() @@ -145,8 +139,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc $r = $this->parseRequest(); $payload = 'xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response(); - header("Content-Type: text/xml"); - header("Content-Length: ".strlen($payload)); + header('Content-Type: text/xml'); + header('Content-Length: '.strlen($payload)); exit($payload); } @@ -155,7 +149,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Add Method to Class * - * @access public * @param string method name * @param string function * @param string signature @@ -176,7 +169,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Parse Server Request * - * @access public * @param string data * @return object xmlrpc response */ @@ -198,7 +190,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- $parser = xml_parser_create($this->xmlrpc_defencoding); - $parser_object = new XML_RPC_Message("filler"); + $parser_object = new XML_RPC_Message('filler'); $parser_object->xh[$parser] = array( 'isf' => 0, @@ -215,7 +207,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc xml_set_character_data_handler($parser, 'character_data'); //xml_set_default_handler($parser, 'default_handler'); - //------------------------------------- // PARSE + PROCESS XML DATA //------------------------------------- @@ -245,7 +236,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc { if ($this->debug === TRUE) { - $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n"; + $plist .= $i.' - '.print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE).";\n"; } $m->addParam($parser_object->xh[$parser]['params'][$i]); @@ -276,7 +267,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Executes the Method * - * @access protected * @param object * @return mixed */ @@ -305,7 +295,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc // Check for Method (and Object) //------------------------------------- - $method_parts = explode(".", $this->methods[$methName]['function']); + $method_parts = explode('.', $this->methods[$methName]['function']); $objectCall = (isset($method_parts[1]) && $method_parts[1] != ''); if ($system_call === TRUE) @@ -315,14 +305,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } } - else + elseif (($objectCall && ! is_callable(array($method_parts[0], $method_parts[1]))) + OR ( ! $objectCall && ! is_callable($this->methods[$methName]['function'])) + ) { - if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1]))) - OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function'])) - ) - { - return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); - } + return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } //------------------------------------- @@ -351,7 +338,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['incorrect_params'], $this->xmlrpcstr['incorrect_params'] . - ": Wanted {$wanted}, got {$pt} at param {$pno})"); + ': Wanted '.$wanted.', got '.$pt.' at param '.$pno.')'); } } } @@ -393,7 +380,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: List Methods * - * @access public * @param mixed * @return object */ @@ -409,7 +395,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc foreach ($this->system_methods as $key => $value) { - $output[]= new XML_RPC_Values($key, 'string'); + $output[] = new XML_RPC_Values($key, 'string'); } $v->addArray($output); @@ -421,7 +407,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: Return Signature for Method * - * @access public * @param mixed * @return object */ @@ -447,18 +432,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc } $sigs[] = new XML_RPC_Values($cursig, 'array'); } - $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array')); - } - else - { - $r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string')); + + return new XML_RPC_Response(new XML_RPC_Values($sigs, 'array')); } + + return new XML_RPC_Response(new XML_RPC_Values('undef', 'string')); } - else - { - $r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); - } - return $r; + + return new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); } // -------------------------------------------------------------------- @@ -466,7 +447,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: Doc String for Method * - * @access public * @param mixed * @return object */ @@ -492,7 +472,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: Multi-call * - * @access public * @param mixed * @return object */ @@ -536,7 +515,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Multi-call Function: Error Handling * - * @access public * @param mixed * @return object */ @@ -556,7 +534,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Multi-call Function: Processes method * - * @access public * @param mixed * @return object */ @@ -610,7 +587,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc } } -// END XML_RPC_Server class /* End of file Xmlrpcs.php */ -/* Location: ./system/libraries/Xmlrpcs.php */ +/* Location: ./system/libraries/Xmlrpcs.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From d69082b8af130ac74806203140a391fc8ca18b82 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 16:14:26 +0300 Subject: Remove access description lines and cleanup the Typography library --- system/libraries/Typography.php | 53 ++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) (limited to 'system') diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 65e30b089..21bbad038 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -25,13 +25,11 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Typography Class * - * - * @access protected + * @package CodeIgniter + * @subpackage Libraries * @category Helpers * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/typography.html @@ -67,7 +65,6 @@ class CI_Typography { * - Converts double dashes into em-dashes. * - Converts two spaces into entities * - * @access public * @param string * @param bool whether to reduce more then two consecutive newlines to two * @return string @@ -94,15 +91,12 @@ class CI_Typography { // HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed $html_comments = array(); - if (strpos($str, '", - "'", - "<", - ">", - '"', - '&', - '$', - '=', - ';', - '?', - '/', - "%20", - "%22", - "%3c", // < - "%253c", // < - "%3e", // > - "%0e", // > - "%28", // ( - "%29", // ) - "%2528", // ( - "%26", // & - "%24", // $ - "%3f", // ? - "%3b", // ; - "%3d" // = - ); - - $filename = str_replace($bad, '', $filename); - - return stripslashes($filename); + '', + "'", '"', + '<', '>', + '&', '$', + '=', + ';', + '?', + '/', + '%20', + '%22', + '%3c', // < + '%253c', // < + '%3e', // > + '%0e', // > + '%28', // ( + '%29', // ) + '%2528', // ( + '%26', // & + '%24', // $ + '%3f', // ? + '%3b', // ; + '%3d' // = + ); + + return stripslashes(str_replace($bad, '', $filename)); } // -------------------------------------------------------------------- @@ -847,7 +817,7 @@ class CI_Upload { $current = ini_get('memory_limit') * 1024 * 1024; // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output - // into scientific notation. number_format() ensures this number is an integer + // into scientific notation. number_format() ensures this number is an integer // http://bugs.php.net/bug.php?id=43053 $new_memory = number_format(ceil(filesize($file) + $current), 0, '.', ''); @@ -857,8 +827,8 @@ class CI_Upload { // If the file being uploaded is an image, then we should have no problem with XSS attacks (in theory), but // IE can be fooled into mime-type detecting a malformed image as an html file, thus executing an XSS attack on anyone - // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this - // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of + // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this + // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of // processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an // attempted XSS attack. @@ -932,7 +902,7 @@ class CI_Upload { */ public function display_errors($open = '

', $close = '

') { - return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : ''; + return (count($this->error_msg) > 0) ? $open.implode($close.$open, $this->error_msg).$close : ''; } // -------------------------------------------------------------------- @@ -940,7 +910,7 @@ class CI_Upload { /** * List of Mime Types * - * This is a list of mime types. We use it to validate + * This is a list of mime types. We use it to validate * the "allowed types" set by the developer * * @param string @@ -952,7 +922,7 @@ class CI_Upload { if (count($this->mimes) == 0) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } @@ -966,10 +936,9 @@ class CI_Upload { } $this->mimes = $mimes; - unset($mimes); } - return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime]; + return isset($this->mimes[$mime]) ? $this->mimes[$mime] : FALSE; } // -------------------------------------------------------------------- @@ -1006,9 +975,7 @@ class CI_Upload { } } - $filename .= '.'.$ext; - - return $filename; + return $filename.'.'.$ext; } // -------------------------------------------------------------------- @@ -1129,10 +1096,7 @@ class CI_Upload { $this->file_type = $file['type']; } - // -------------------------------------------------------------------- - } -// END Upload Class /* End of file Upload.php */ -/* Location: ./system/libraries/Upload.php */ +/* Location: ./system/libraries/Upload.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 8486e9cbdd28e80b41e517afe786e9b0c917af8a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 20:24:12 +0300 Subject: Renamed (with an underscore prefix) and switched from private to protected properties in the Driver library --- system/libraries/Driver.php | 52 ++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) (limited to 'system') diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 9a073b336..f409f47d4 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Driver Library Class * @@ -84,8 +82,8 @@ class CI_Driver_Library { // it's a valid driver, but the file simply can't be found if ( ! class_exists($child_class)) { - log_message('error', "Unable to load the requested driver: ".$child_class); - show_error("Unable to load the requested driver: ".$child_class); + log_message('error', 'Unable to load the requested driver: '.$child_class); + show_error('Unable to load the requested driver: '.$child_class); } } @@ -96,15 +94,11 @@ class CI_Driver_Library { } // The requested driver isn't valid! - log_message('error', "Invalid driver requested: ".$child_class); - show_error("Invalid driver requested: ".$child_class); + log_message('error', 'Invalid driver requested: '.$child_class); + show_error('Invalid driver requested: '.$child_class); } - // -------------------------------------------------------------------- - } -// END CI_Driver_Library CLASS - /** * CodeIgniter Driver Class @@ -120,12 +114,12 @@ class CI_Driver_Library { */ class CI_Driver { - protected $parent; + protected $_parent; - private $methods = array(); - private $properties = array(); + protected $_methods = array(); + protected $_properties = array(); - private static $reflections = array(); + protected static $_reflections = array(); /** * Decorate @@ -137,14 +131,14 @@ class CI_Driver { */ public function decorate($parent) { - $this->parent = $parent; + $this->_parent = $parent; // Lock down attributes to what is defined in the class // and speed up references in magic methods $class_name = get_class($parent); - if ( ! isset(self::$reflections[$class_name])) + if ( ! isset(self::$_reflections[$class_name])) { $r = new ReflectionObject($parent); @@ -152,7 +146,7 @@ class CI_Driver { { if ($method->isPublic()) { - $this->methods[] = $method->getName(); + $this->_methods[] = $method->getName(); } } @@ -160,15 +154,15 @@ class CI_Driver { { if ($prop->isPublic()) { - $this->properties[] = $prop->getName(); + $this->_properties[] = $prop->getName(); } } - self::$reflections[$class_name] = array($this->methods, $this->properties); + self::$_reflections[$class_name] = array($this->_methods, $this->_properties); } else { - list($this->methods, $this->properties) = self::$reflections[$class_name]; + list($this->_methods, $this->_properties) = self::$_reflections[$class_name]; } } @@ -179,16 +173,15 @@ class CI_Driver { * * Handles access to the parent driver library's methods * - * @access public * @param string * @param array * @return mixed */ public function __call($method, $args = array()) { - if (in_array($method, $this->methods)) + if (in_array($method, $this->_methods)) { - return call_user_func_array(array($this->parent, $method), $args); + return call_user_func_array(array($this->_parent, $method), $args); } $trace = debug_backtrace(); @@ -208,9 +201,9 @@ class CI_Driver { */ public function __get($var) { - if (in_array($var, $this->properties)) + if (in_array($var, $this->_properties)) { - return $this->parent->$var; + return $this->_parent->$var; } } @@ -227,16 +220,13 @@ class CI_Driver { */ public function __set($var, $val) { - if (in_array($var, $this->properties)) + if (in_array($var, $this->_properties)) { - $this->parent->$var = $val; + $this->_parent->$var = $val; } } - // -------------------------------------------------------------------- - } -// END CI_Driver CLASS /* End of file Driver.php */ -/* Location: ./system/libraries/Driver.php */ +/* Location: ./system/libraries/Driver.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 627e172fd3ada0fc2b648a3fff10af4a0022378f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 20:53:47 +0300 Subject: Remove access description lines and cleanup the download, language, number, path & xml helpers --- system/helpers/download_helper.php | 3 +-- system/helpers/language_helper.php | 7 ++----- system/helpers/number_helper.php | 5 +---- system/helpers/path_helper.php | 3 +-- system/helpers/xml_helper.php | 14 ++++++-------- 5 files changed, 11 insertions(+), 21 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 96ff29dec..19192a147 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -42,7 +42,6 @@ * * Generates headers that force a download to happen * - * @access public * @param string filename * @param mixed the data to be downloaded * @param bool wether to try and send the actual file MIME type @@ -125,4 +124,4 @@ if ( ! function_exists('force_download')) } /* End of file download_helper.php */ -/* Location: ./system/helpers/download_helper.php */ +/* Location: ./system/helpers/download_helper.php */ \ No newline at end of file diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php index 1d66df59f..b31c97107 100644 --- a/system/helpers/language_helper.php +++ b/system/helpers/language_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Language Helpers * @@ -44,7 +42,6 @@ * * Fetches a language variable and optionally outputs a form label * - * @access public * @param string the language line * @param string the id of the form element * @return string @@ -58,7 +55,7 @@ if ( ! function_exists('lang')) if ($id != '') { - $line = '"; + $line = ''; } return $line; @@ -66,4 +63,4 @@ if ( ! function_exists('lang')) } /* End of file language_helper.php */ -/* Location: ./system/helpers/language_helper.php */ +/* Location: ./system/helpers/language_helper.php */ \ No newline at end of file diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php index b6c823d8b..40da6e7bf 100644 --- a/system/helpers/number_helper.php +++ b/system/helpers/number_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Number Helpers * @@ -42,7 +40,6 @@ /** * Formats a numbers as bytes, based on size, and adds the appropriate suffix * - * @access public * @param mixed // will be cast as int * @return string */ @@ -84,4 +81,4 @@ if ( ! function_exists('byte_format')) } /* End of file number_helper.php */ -/* Location: ./system/helpers/number_helper.php */ +/* Location: ./system/helpers/number_helper.php */ \ No newline at end of file diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index c31f0bdc5..6ee99072c 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -40,7 +40,6 @@ /** * Set Realpath * - * @access public * @param string * @param bool checks to see if the path exists * @return string @@ -71,4 +70,4 @@ if ( ! function_exists('set_realpath')) } /* End of file path_helper.php */ -/* Location: ./system/helpers/path_helper.php */ +/* Location: ./system/helpers/path_helper.php */ \ No newline at end of file diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php index f3ff5764c..67fd34b97 100644 --- a/system/helpers/xml_helper.php +++ b/system/helpers/xml_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter XML Helpers * @@ -42,8 +40,8 @@ /** * Convert Reserved XML characters to Entities * - * @access public * @param string + * @param bool * @return string */ if ( ! function_exists('xml_convert')) @@ -54,11 +52,11 @@ if ( ! function_exists('xml_convert')) // Replace entities to temporary markers so that // ampersands won't get messed up - $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str); + $str = preg_replace('/&#(\d+);/', $temp.'\\1;', $str); if ($protect_all == TRUE) { - $str = preg_replace('/&(\w+);/', "$temp\\1;", $str); + $str = preg_replace('/&(\w+);/', $temp.'\\1;', $str); } $str = str_replace(array('&', '<', '>', '"', "'", '-'), @@ -66,11 +64,11 @@ if ( ! function_exists('xml_convert')) $str); // Decode the temp markers back to entities - $str = preg_replace('/$temp(\d+);/', '&#\\1;', $str); + $str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str); if ($protect_all == TRUE) { - return preg_replace("/$temp(\w+);/", '&\\1;', $str); + return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str); } return $str; @@ -78,4 +76,4 @@ if ( ! function_exists('xml_convert')) } /* End of file xml_helper.php */ -/* Location: ./system/helpers/xml_helper.php */ +/* Location: ./system/helpers/xml_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 2046b1a14f68495e6324edb26250916037bce9e1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 21:07:04 +0300 Subject: Remove access description lines and cleanup the html helper --- system/helpers/html_helper.php | 66 ++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 41 deletions(-) (limited to 'system') diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index b8c4f36f6..0417bd253 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter HTML Helpers * @@ -42,12 +40,10 @@ /** * Heading * - * Generates an HTML heading tag. First param is the data. - * Second param is the size of the heading tag. + * Generates an HTML heading tag. * - * @access public - * @param string - * @param integer + * @param string content + * @param int heading level * @return string */ if ( ! function_exists('heading')) @@ -65,7 +61,6 @@ if ( ! function_exists('heading')) * * Generates an HTML unordered list from an single or multi-dimensional array. * - * @access public * @param array * @param mixed * @return string @@ -85,7 +80,6 @@ if ( ! function_exists('ul')) * * Generates an HTML ordered list from an single or multi-dimensional array. * - * @access public * @param array * @param mixed * @return string @@ -105,11 +99,10 @@ if ( ! function_exists('ol')) * * Generates an HTML ordered list from an single or multi-dimensional array. * - * @access private * @param string * @param mixed * @param mixed - * @param integer + * @param int * @return string */ if ( ! function_exists('_list')) @@ -131,13 +124,13 @@ if ( ! function_exists('_list')) $atts = ''; foreach ($attributes as $key => $val) { - $atts .= ' ' . $key . '="' . $val . '"'; + $atts .= ' '.$key.'="'.$val.'"'; } $attributes = $atts; } - elseif (is_string($attributes) AND strlen($attributes) > 0) + elseif (is_string($attributes) && strlen($attributes) > 0) { - $attributes = ' '. $attributes; + $attributes = ' '.$attributes; } // Write the opening list tag @@ -175,8 +168,7 @@ if ( ! function_exists('_list')) /** * Generates HTML BR tags based on number supplied * - * @access public - * @param integer + * @param int * @return string */ if ( ! function_exists('br')) @@ -194,8 +186,8 @@ if ( ! function_exists('br')) * * Generates an element * - * @access public * @param mixed + * @param bool * @return string */ if ( ! function_exists('img')) @@ -217,7 +209,7 @@ if ( ! function_exists('img')) foreach ($src as $k => $v) { - if ($k === 'src' AND strpos($v, '://') === FALSE) + if ($k === 'src' && strpos($v, '://') === FALSE) { $CI =& get_instance(); @@ -232,7 +224,7 @@ if ( ! function_exists('img')) } else { - $img .= " $k=\"$v\""; + $img .= ' '.$k.'="'.$v.'"'; } } @@ -248,10 +240,9 @@ if ( ! function_exists('img')) * Generates a page document type declaration * * Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame, - * html4-strict, html4-trans, and html4-frame. Values are saved in the + * html4-strict, html4-trans, and html4-frame. Values are saved in the * doctypes config file. * - * @access public * @param string type The doctype to be generated * @return string */ @@ -263,7 +254,7 @@ if ( ! function_exists('doctype')) if ( ! is_array($_doctypes)) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); } @@ -278,7 +269,7 @@ if ( ! function_exists('doctype')) } } - return (isset($_doctypes[$type])) ? $_doctypes[$type] : FALSE; + return isset($_doctypes[$type]) ? $_doctypes[$type] : FALSE; } } @@ -289,13 +280,12 @@ if ( ! function_exists('doctype')) * * Generates link to a CSS file * - * @access public * @param mixed stylesheet hrefs or an array * @param string rel * @param string type * @param string title * @param string media - * @param boolean should index_page be added to the css path + * @param bool should index_page be added to the css path * @return string */ if ( ! function_exists('link_tag')) @@ -309,7 +299,7 @@ if ( ! function_exists('link_tag')) { foreach ($href as $k => $v) { - if ($k === 'href' AND strpos($v, '://') === FALSE) + if ($k === 'href' && strpos($v, '://') === FALSE) { if ($index_page === TRUE) { @@ -322,11 +312,9 @@ if ( ! function_exists('link_tag')) } else { - $link .= "$k=\"$v\" "; + $link .= $k.'="'.$v.'" '; } } - - $link .= '/>'; } else { @@ -354,11 +342,9 @@ if ( ! function_exists('link_tag')) { $link .= 'title="'.$title.'" '; } - - $link .= '/>'; } - return $link."\n"; + return $link."/>\n"; } } @@ -367,8 +353,10 @@ if ( ! function_exists('link_tag')) /** * Generates meta tags from an array of key/values * - * @access public * @param array + * @param string + * @param string + * @param string * @return string */ if ( ! function_exists('meta')) @@ -381,13 +369,10 @@ if ( ! function_exists('meta')) { $name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline)); } - else + elseif (isset($name['name'])) { // Turn single array into multidimensional - if (isset($name['name'])) - { - $name = array($name); - } + $name = array($name); } $str = ''; @@ -410,8 +395,7 @@ if ( ! function_exists('meta')) /** * Generates non-breaking space entities based on number supplied * - * @access public - * @param integer + * @param int * @return string */ if ( ! function_exists('nbs')) @@ -423,4 +407,4 @@ if ( ! function_exists('nbs')) } /* End of file html_helper.php */ -/* Location: ./system/helpers/html_helper.php */ +/* Location: ./system/helpers/html_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 93a83c720e69d1d363896f6b685d2b7ef475ebbc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 21:24:02 +0300 Subject: Remove access description lines and cleanup the form helper --- system/helpers/form_helper.php | 161 ++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 105 deletions(-) (limited to 'system') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 37337d975..ada822860 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -24,8 +24,6 @@ * @since Version 1.0 */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Form Helpers * @@ -43,7 +41,6 @@ * * Creates the opening portion of the form. * - * @access public * @param string the URI segments of the form destination * @param array a key/value pair of attributes * @param array a key/value pair hidden data @@ -71,15 +68,15 @@ if ( ! function_exists('form_open')) $form = '\n"; - // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites - if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"'))) + // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites + if ($CI->config->item('csrf_protection') === TRUE && ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"'))) { $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } - if (is_array($hidden) AND count($hidden) > 0) + if (is_array($hidden) && count($hidden) > 0) { - $form .= sprintf("
%s
", form_hidden($hidden)); + $form .= sprintf('
%s
', form_hidden($hidden)); } return $form; @@ -93,7 +90,6 @@ if ( ! function_exists('form_open')) * * Creates the opening portion of the form, but with "multipart/form-data". * - * @access public * @param string the URI segments of the form destination * @param array a key/value pair of attributes * @param array a key/value pair hidden data @@ -121,10 +117,9 @@ if ( ! function_exists('form_open_multipart')) /** * Hidden Input Field * - * Generates hidden fields. You can pass a simple key/value string or an associative - * array with multiple values. + * Generates hidden fields. You can pass a simple key/value string or + * an associative array with multiple values. * - * @access public * @param mixed * @param string * @return string @@ -157,7 +152,7 @@ if ( ! function_exists('form_hidden')) { foreach ($value as $k => $v) { - $k = (is_int($k)) ? '' : $k; + $k = is_int($k) ? '' : $k; form_hidden($name.'['.$k.']', $v, TRUE); } } @@ -171,7 +166,6 @@ if ( ! function_exists('form_hidden')) /** * Text Input Field * - * @access public * @param mixed * @param string * @param string @@ -181,7 +175,7 @@ if ( ! function_exists('form_input')) { function form_input($data = '', $value = '', $extra = '') { - $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + $defaults = array('type' => 'text', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); return '\n"; } @@ -194,7 +188,6 @@ if ( ! function_exists('form_input')) * * Identical to the input function but adds the "password" type * - * @access public * @param mixed * @param string * @param string @@ -221,7 +214,6 @@ if ( ! function_exists('form_password')) * * Identical to the input function but adds the "file" type * - * @access public * @param mixed * @param string * @param string @@ -246,7 +238,6 @@ if ( ! function_exists('form_upload')) /** * Textarea field * - * @access public * @param mixed * @param string * @param string @@ -256,7 +247,7 @@ if ( ! function_exists('form_textarea')) { function form_textarea($data = '', $value = '', $extra = '') { - $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '40', 'rows' => '10'); + $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'cols' => '40', 'rows' => '10'); if ( ! is_array($data) OR ! isset($data['value'])) { @@ -268,7 +259,7 @@ if ( ! function_exists('form_textarea')) unset($data['value']); // textareas don't use the value attribute } - $name = (is_array($data)) ? $data['name'] : $data; + $name = is_array($data) ? $data['name'] : $data; return '\n"; } } @@ -278,12 +269,11 @@ if ( ! function_exists('form_textarea')) /** * Multi-select menu * - * @access public * @param string * @param array * @param mixed * @param string - * @return type + * @return string */ if ( ! function_exists('form_multiselect')) { @@ -303,7 +293,6 @@ if ( ! function_exists('form_multiselect')) /** * Drop-down Menu * - * @access public * @param string * @param array * @param string @@ -314,28 +303,16 @@ if ( ! function_exists('form_dropdown')) { function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') { - // If name is really an array then we'll call the function again using the array - if (is_array($name) && isset($name['name'])) - { - - if ( ! isset($name['options'])) - { - $name['options'] = array(); - } - - if ( ! isset($name['selected'])) - { - $name['selected'] = array(); - } - - if ( ! isset($name['extra'])) - { - $name['extra'] = ''; - } - - return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']); - } - + // If name is really an array then we'll call the function again using the array + if (is_array($name) && isset($name['name'])) + { + isset($name['options']) OR $name['options'] = array(); + isset($name['selected']) OR $name['selected'] = array(); + isset($name['extra']) OR $name['extra'] = array(); + + return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']); + } + if ( ! is_array($selected)) { $selected = array($selected); @@ -363,11 +340,11 @@ if ( ! function_exists('form_dropdown')) foreach ($val as $optgroup_key => $optgroup_val) { - $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : ''; + $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : ''; $form .= '\n"; } - $form .= ''."\n"; + $form .= "\n"; } else { @@ -375,9 +352,7 @@ if ( ! function_exists('form_dropdown')) } } - $form .= "\n"; - - return $form; + return $form."\n"; } } @@ -386,7 +361,6 @@ if ( ! function_exists('form_dropdown')) /** * Checkbox Field * - * @access public * @param mixed * @param string * @param bool @@ -397,9 +371,9 @@ if ( ! function_exists('form_checkbox')) { function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '') { - $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + $defaults = array('type' => 'checkbox', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); - if (is_array($data) AND array_key_exists('checked', $data)) + if (is_array($data) && array_key_exists('checked', $data)) { $checked = $data['checked']; @@ -431,7 +405,6 @@ if ( ! function_exists('form_checkbox')) /** * Radio Button * - * @access public * @param mixed * @param string * @param bool @@ -457,7 +430,6 @@ if ( ! function_exists('form_radio')) /** * Submit Button * - * @access public * @param mixed * @param string * @param string @@ -467,7 +439,7 @@ if ( ! function_exists('form_submit')) { function form_submit($data = '', $value = '', $extra = '') { - $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + $defaults = array('type' => 'submit', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); return '\n"; } } @@ -477,7 +449,6 @@ if ( ! function_exists('form_submit')) /** * Reset Button * - * @access public * @param mixed * @param string * @param string @@ -487,7 +458,7 @@ if ( ! function_exists('form_reset')) { function form_reset($data = '', $value = '', $extra = '') { - $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + $defaults = array('type' => 'reset', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); return '\n"; } } @@ -497,7 +468,6 @@ if ( ! function_exists('form_reset')) /** * Form Button * - * @access public * @param mixed * @param string * @param string @@ -507,8 +477,8 @@ if ( ! function_exists('form_button')) { function form_button($data = '', $content = '', $extra = '') { - $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button'); - if ( is_array($data) AND isset($data['content'])) + $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'type' => 'button'); + if (is_array($data) && isset($data['content'])) { $content = $data['content']; unset($data['content']); // content is not an attribute @@ -523,7 +493,6 @@ if ( ! function_exists('form_button')) /** * Form Label Tag * - * @access public * @param string The text to appear onscreen * @param string The id the label applies to * @param string Additional attributes @@ -538,10 +507,10 @@ if ( ! function_exists('form_label')) if ($id != '') { - $label .= " for=\"$id\""; + $label .= ' for="'.$id.'"'; } - if (is_array($attributes) AND count($attributes) > 0) + if (is_array($attributes) && count($attributes) > 0) { foreach ($attributes as $key => $val) { @@ -549,7 +518,7 @@ if ( ! function_exists('form_label')) } } - return $label .= ">$label_text"; + return $label.'>'.$label_text.''; } } @@ -560,7 +529,6 @@ if ( ! function_exists('form_label')) * Used to produce
text. To close fieldset * use form_fieldset_close() * - * @access public * @param string The legend text * @param string Additional attributes * @return string @@ -572,7 +540,7 @@ if ( ! function_exists('form_fieldset')) $fieldset = '\n"; if ($legend_text != '') { - $fieldset .= "$legend_text\n"; + return $fieldset.''.$legend_text."\n"; } return $fieldset; @@ -584,7 +552,6 @@ if ( ! function_exists('form_fieldset')) /** * Fieldset Close Tag * - * @access public * @param string * @return string */ @@ -592,7 +559,7 @@ if ( ! function_exists('form_fieldset_close')) { function form_fieldset_close($extra = '') { - return "
".$extra; + return ''.$extra; } } @@ -601,7 +568,6 @@ if ( ! function_exists('form_fieldset_close')) /** * Form Close Tag * - * @access public * @param string * @return string */ @@ -609,7 +575,7 @@ if ( ! function_exists('form_close')) { function form_close($extra = '') { - return "".$extra; + return ''.$extra; } } @@ -670,10 +636,9 @@ if ( ! function_exists('form_prep')) * Form Value * * Grabs a value from the POST array for the specified field so you can - * re-populate an input field or textarea. If Form Validation + * re-populate an input field or textarea. If Form Validation * is active it retrieves the info from the validation class * - * @access public * @param string * @return mixed */ @@ -703,7 +668,6 @@ if ( ! function_exists('set_value')) * Let's you set the selected value of a