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(-) 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 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 +++++++++++++- .../source/libraries/form_validation.rst | 60 ++++++++++++---------- 3 files changed, 94 insertions(+), 52 deletions(-) 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.) * diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index e7875bc22..185850b5a 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -823,34 +823,38 @@ Rule Reference The following is a list of all the native rules that are available to use: -======================= ========== ============================================================================================= ======================= -Rule Parameter Description Example -======================= ========== ============================================================================================= ======================= -**required** No Returns FALSE if the form element is empty. -**matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] -**is_unique** Yes Returns FALSE if the form element is not unique to the is_unique[table.field] - table and field name in the parameter. is_unique[table.field] -**max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] -**exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] -**greater_than** Yes Returns FALSE if the form element is less than the parameter value or not numeric. greater_than[8] -**less_than** Yes Returns FALSE if the form element is greater than the parameter value or not numeric. less_than[8] -**alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. -**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. -**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, - underscores or dashes. -**numeric** No Returns FALSE if the form element contains anything other than numeric characters. -**integer** No Returns FALSE if the form element contains anything other than an integer. -**decimal** Yes Returns FALSE if the form element is not exactly the parameter value. -**is_natural** No Returns FALSE if the form element contains anything other than a natural number: - 0, 1, 2, 3, etc. -**is_natural_no_zero** No Returns FALSE if the form element contains anything other than a natural - number, but not zero: 1, 2, 3, etc. -**is_unique** Yes Returns FALSE if the form element is not unique in a database table. is_unique[table.field] -**valid_email** No Returns FALSE if the form element does not contain a valid email address. -**valid_emails** No Returns FALSE if any value provided in a comma separated list is not a valid email. -**valid_ip** No Returns FALSE if the supplied IP is not valid. -**valid_base64** No Returns FALSE if the supplied string contains anything other than valid Base64 characters. -======================= ========== ============================================================================================= ======================= +========================= ========== ============================================================================================= ======================= +Rule Parameter Description Example +========================= ========== ============================================================================================= ======================= +**required** No Returns FALSE if the form element is empty. +**matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] +**is_unique** Yes Returns FALSE if the form element is not unique to the is_unique[table.field] + table and field name in the parameter. is_unique[table.field] +**max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] +**exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] +**greater_than** Yes Returns FALSE if the form element is less than the parameter value or not numeric. greater_than[8] +**equal_to_greater_than** Yes Returns FALSE if the form element is not equal to or less than the parameter value, greater_than[8] + or not numeric. +**less_than** Yes Returns FALSE if the form element is greater than the parameter value or not numeric. less_than[8] +**equal_to_less_than** Yes Returns FALSE if the form element is not equal to or greater than the parameter value, less_than[8] + or not numeric. +**alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. +**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. +**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, + underscores or dashes. +**numeric** No Returns FALSE if the form element contains anything other than numeric characters. +**integer** No Returns FALSE if the form element contains anything other than an integer. +**decimal** Yes Returns FALSE if the form element is not exactly the parameter value. +**is_natural** No Returns FALSE if the form element contains anything other than a natural number: + 0, 1, 2, 3, etc. +**is_natural_no_zero** No Returns FALSE if the form element contains anything other than a natural + number, but not zero: 1, 2, 3, etc. +**is_unique** Yes Returns FALSE if the form element is not unique in a database table. is_unique[table.field] +**valid_email** No Returns FALSE if the form element does not contain a valid email address. +**valid_emails** No Returns FALSE if any value provided in a comma separated list is not a valid email. +**valid_ip** No Returns FALSE if the supplied IP is not valid. +**valid_base64** No Returns FALSE if the supplied string contains anything other than valid Base64 characters. +========================= ========== ============================================================================================= ======================= .. note:: These rules can also be called as discrete functions. For example:: -- 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 ++-- user_guide_src/source/libraries/form_validation.rst | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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)) { diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 185850b5a..0ca6e767b 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -833,10 +833,10 @@ Rule Parameter Description **max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] **exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] **greater_than** Yes Returns FALSE if the form element is less than the parameter value or not numeric. greater_than[8] -**equal_to_greater_than** Yes Returns FALSE if the form element is not equal to or less than the parameter value, greater_than[8] +**greater_than_equal_to** Yes Returns FALSE if the form element is not equal to or less than the parameter value, greater_than[8] or not numeric. **less_than** Yes Returns FALSE if the form element is greater than the parameter value or not numeric. less_than[8] -**equal_to_less_than** Yes Returns FALSE if the form element is not equal to or greater than the parameter value, less_than[8] +**less_than_equal_to** Yes Returns FALSE if the form element is not equal to or greater than the parameter value, less_than[8] or not numeric. **alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. **alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. -- 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 +++--- user_guide_src/source/libraries/form_validation.rst | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) 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 */ diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 0ca6e767b..684051db5 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -832,11 +832,13 @@ Rule Parameter Description table and field name in the parameter. is_unique[table.field] **max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] **exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] -**greater_than** Yes Returns FALSE if the form element is less than the parameter value or not numeric. greater_than[8] -**greater_than_equal_to** Yes Returns FALSE if the form element is not equal to or less than the parameter value, greater_than[8] +**greater_than** Yes Returns FALSE if the form element is less than or equal to the parameter value or not greater_than[8] + numeric. +**greater_than_equal_to** Yes Returns FALSE if the form element is less than the parameter value, greater_than_equal_to[8] or not numeric. -**less_than** Yes Returns FALSE if the form element is greater than the parameter value or not numeric. less_than[8] -**less_than_equal_to** Yes Returns FALSE if the form element is not equal to or greater than the parameter value, less_than[8] +**less_than** Yes Returns FALSE if the form element is greater than or equal to the parameter value or less_than[8] + not numeric. +**less_than_equal_to** Yes Returns FALSE if the form element is greater than the parameter value, less_than_equal_to[8] or not numeric. **alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. **alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. -- 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 ++++ user_guide_src/source/changelog.rst | 1 + 6 files changed, 1247 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 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 diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index faea35872..1e6248f63 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -51,6 +51,7 @@ Release Date: Not Released - MySQLi driver now supports persistent connections when running on PHP >= 5.3. - Added dsn if the group connections in the config use PDO or any driver which need DSN. - Improved PDO database support. + - Added Interbase/Firebird database support via the "interbase" driver - Libraries -- 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 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(-) 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 ++++--- user_guide_src/source/database/helpers.rst | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) 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); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/database/helpers.rst b/user_guide_src/source/database/helpers.rst index 7ea19e9f6..e8a5ac801 100644 --- a/user_guide_src/source/database/helpers.rst +++ b/user_guide_src/source/database/helpers.rst @@ -7,9 +7,9 @@ $this->db->insert_id() The insert ID number when performing database inserts. -.. note:: If using the PDO driver with PostgreSQL, this function requires - a $name parameter, which specifies the appropriate sequence to check - for the insert id. +.. note:: If using the PDO driver with PostgreSQL, or using the Interbase + driver, this function requires a $name parameter, which specifies the + appropriate sequence to check for the insert id. $this->db->affected_rows() =========================== -- 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(-) 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(-) 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(-) 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 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(+) 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(-) 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(-) 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 2d04624cb59d5852f8e61d610ab822252cad685a Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 16:31:51 -0500 Subject: Added unprefixed css property to welcome view --- application/views/welcome_message.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php index acc36b6d4..4d9161aa0 100644 --- a/application/views/welcome_message.php +++ b/application/views/welcome_message.php @@ -89,6 +89,8 @@ margin: 10px; border: 1px solid #D0D0D0; -webkit-box-shadow: 0 0 8px #D0D0D0; + -moz-box-shadow: 0 0 8px #D0D0D0; + box-shadow: 0 0 8px #D0D0D0; } -- 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(-) 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 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 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 +++++++++++++++----- user_guide_src/source/database/utilities.rst | 6 +++++- 3 files changed, 23 insertions(+), 6 deletions(-) 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; + } } } diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst index b0920109f..3805ffb87 100644 --- a/user_guide_src/source/database/utilities.rst +++ b/user_guide_src/source/database/utilities.rst @@ -161,7 +161,11 @@ $this->dbutil->backup() Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format. -.. note:: This features is only available for MySQL databases. +.. note:: This features is only available for MySQL and Interbase/Firebird databases. + +.. note:: For Interbase/Firebird databases, the backup file name is the only parameter. + + Eg. $this->dbutil->backup('db_backup_filename'); .. note:: Due to the limited execution time and memory available to PHP, backing up very large databases may not be possible. If your database is -- 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(-) 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 +++++++++++++++- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/libraries/table.rst | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) 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; + } } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index dc6b29516..0e5fea491 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -72,6 +72,7 @@ Release Date: Not Released - Minor speed optimizations and method & property visibility declarations in the Calendar Library. - Removed SHA1 function in the :doc:`Encryption Library `. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. + - Allowed for setting table class defaults in a config file. - Core diff --git a/user_guide_src/source/libraries/table.rst b/user_guide_src/source/libraries/table.rst index 9bc3f3423..6a808abc2 100644 --- a/user_guide_src/source/libraries/table.rst +++ b/user_guide_src/source/libraries/table.rst @@ -116,6 +116,8 @@ example, only the table opening tag is being changed:: $tmpl = array ( 'table_open' => '' ); $this->table->set_template($tmpl); + +You can also set defaults for these in a config file. ****************** Function Reference -- 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 ++++++++++++++++++++++ user_guide_src/source/changelog.rst | 1 + .../source/libraries/form_validation.rst | 8 +++++++- 3 files changed, 32 insertions(+), 1 deletion(-) 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']); + } + } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index dc6b29516..3aa9d6573 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -72,6 +72,7 @@ Release Date: Not Released - Minor speed optimizations and method & property visibility declarations in the Calendar Library. - Removed SHA1 function in the :doc:`Encryption Library `. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. + - Form Validation library now allows setting of error delimiters in the config file via $config['error_prefix'] and $config['error_suffix']. - Core diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index e7875bc22..1b3fa61d1 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -523,7 +523,7 @@ Changing the Error Delimiters By default, the Form Validation class adds a paragraph tag (

) around each error message shown. You can either change these delimiters -globally or individually. +globally, individually, or change the defaults in a config file. #. **Changing delimiters Globally** To globally change the error delimiters, in your controller function, @@ -543,6 +543,12 @@ globally or individually. ', ''); ?> +#. **Set delimiters in a config file** + You can add your error delimiters in application/config/form_validation.php as follows:: + + $config['error_prefix'] = '

'; + $config['error_suffix'] = '

'; + Showing Errors Individually =========================== -- cgit v1.2.3-24-g4f1b From 571e41eee86494c45f09fc723849011ca5a4f45b Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 10:10:07 -0500 Subject: fixed suffix documentation. --- user_guide_src/source/libraries/form_validation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 1b3fa61d1..36ad85dd2 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -547,7 +547,7 @@ globally, individually, or change the defaults in a config file. You can add your error delimiters in application/config/form_validation.php as follows:: $config['error_prefix'] = '

'; - $config['error_suffix'] = '

'; + $config['error_suffix'] = '

'; Showing Errors Individually -- cgit v1.2.3-24-g4f1b From 840a89396dbd67b7be5539bf2e9ce94274795ad8 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 10:11:37 -0500 Subject: updated documentation to differentiate prefix and suffix more. --- user_guide_src/source/libraries/form_validation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 36ad85dd2..b70fc44d0 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -546,8 +546,8 @@ globally, individually, or change the defaults in a config file. #. **Set delimiters in a config file** You can add your error delimiters in application/config/form_validation.php as follows:: - $config['error_prefix'] = '

'; - $config['error_suffix'] = '

'; + $config['error_prefix'] = '
'; + $config['error_suffix'] = '
'; Showing Errors Individually -- 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(-) 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 04ae0672aa9b9f8e590201e8c3817f307800e2c6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 27 Feb 2012 23:59:18 +0200 Subject: Add changelog entry --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index dc6b29516..7916c4e98 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -108,6 +108,7 @@ Bug fixes for 3.0 - Fixed a possible bug in ``CI_Input::is_ajax_request()`` where some clients might not send the X-Requested-With HTTP header value exactly as 'XmlHttpRequest'. - Fixed a bug (#1039) - MySQL's _backup() method failed due to a table name not being escaped. - Fixed a bug (#1070) - CI_DB_driver::initialize() didn't set a character set if a database is not selected. +- Fixed a bug (#499) - a CSRF cookie was created even with CSRF protection being disabled. Version 2.1.0 ============= -- 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(-) 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(-) 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(-) 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(-) 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 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(-) 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(-) 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 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 ++++++++++++++++++++++ user_guide_src/source/changelog.rst | 1 + 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 system/libraries/Cache/drivers/Cache_wincache.php 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 */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index dc6b29516..e879568ed 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -29,6 +29,7 @@ Release Date: Not Released - Added support for m4a, aac, m4u, xspf, au, ac3, flac, ogg Audio files to mimes.php. - Added support for kmz and kml (Google Earth) files to mimes.php. - Added application/xml for xml and application/xml, text/xsl for xsl in mimes.php. + - Added support for Wincache PHP extension - Changed logger to only chmod when file is first created. - Removed previously deprecated SHA1 Library. - Removed previously deprecated use of ``$autoload['core']`` in application/config/autoload.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(-) 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 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 ++++++------ user_guide/changelog.html | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) 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) { diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 76a0bcb19..b87e61ba8 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -79,6 +79,7 @@ Change Log
  • Fixed a bug - form_open() compared $action against site_url() instead of base_url()
  • Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
  • Fixed a bug (#538) - Windows paths were ignored when using the Image Manipulation Class to create a new file.
  • +
  • Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
  • -- 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 +++++------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) 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 .= "
    \n"; } @@ -311,7 +311,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))) . "
    $_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 */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0446c112d..d652f1cbd 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -122,6 +122,7 @@ Bug fixes for 3.0 - Fixed a bug in CUBRID's affected_rows() method where a connection resource was passed to cubrid_affected_rows() instead of a result. - Fixed a bug (#638) - db_set_charset() ignored its arguments and always used the configured charset and collation instead. - Fixed a bug (#413) - Oracle's _error_message() and _error_number() methods used to only return connection-related errors. +- Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in warnings being issued by htmlspecialchars(). Version 2.1.1 ============= -- 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 ++++++++++++++ user_guide_src/source/changelog.rst | 1 + user_guide_src/source/libraries/form_validation.rst | 9 +++++++++ 3 files changed, 24 insertions(+) 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 * diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d652f1cbd..6505e7489 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -75,6 +75,7 @@ Release Date: Not Released - Minor speed optimizations and method & property visibility declarations in the Calendar Library. - Removed SHA1 function in the :doc:`Encryption Library `. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. + - Added function error_array() to return all error messages as an array in the Form_validation class. - Core diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index e7875bc22..09a192bb0 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -930,6 +930,15 @@ $this->form_validation->set_message(); Permits you to set custom error messages. See :ref:`setting-error-messages` +$this->form_validation->error_array(); +======================================== + + .. php:method:: error_array () + + :rtype: Array + + Returns the error messages as an array. + .. _helper-functions: **************** -- 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 ++++++++----------- user_guide_src/source/changelog.rst | 1 + 3 files changed, 16 insertions(+), 22 deletions(-) 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; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 6505e7489..f827faa9f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -124,6 +124,7 @@ Bug fixes for 3.0 - Fixed a bug (#638) - db_set_charset() ignored its arguments and always used the configured charset and collation instead. - Fixed a bug (#413) - Oracle's _error_message() and _error_number() methods used to only return connection-related errors. - Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in warnings being issued by htmlspecialchars(). +- Fixed a bug (#1101) - MySQL/MySQLi result method field_data() was implemented as if it was handling a DESCRIBE result instead of the actual result set. Version 2.1.1 ============= -- 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 ++++++++--------------------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 18 insertions(+), 47 deletions(-) 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 */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f827faa9f..cece286c5 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -125,6 +125,7 @@ Bug fixes for 3.0 - Fixed a bug (#413) - Oracle's _error_message() and _error_number() methods used to only return connection-related errors. - Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in warnings being issued by htmlspecialchars(). - Fixed a bug (#1101) - MySQL/MySQLi result method field_data() was implemented as if it was handling a DESCRIBE result instead of the actual result set. +- Fixed a bug in Oracle's :doc:`Database Forge Class ` method _create_table() where it failed with AUTO_INCREMENT as it's not supported. Version 2.1.1 ============= -- 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(-) 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 +++++++++------------- user_guide_src/source/changelog.rst | 7 ++-- user_guide_src/source/database/queries.rst | 17 ++++++++ 13 files changed, 122 insertions(+), 205 deletions(-) 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; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index cece286c5..cf139bc1c 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -54,7 +54,8 @@ Release Date: Not Released - MySQLi driver now supports persistent connections when running on PHP >= 5.3. - Added dsn if the group connections in the config use PDO or any driver which need DSN. - Improved PDO database support. - - An optional database name parameter was added db_select(). + - Added an optional database name parameter to db_select(). + - Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message. - Libraries @@ -116,13 +117,13 @@ Bug fixes for 3.0 - Fixed a bug (#81) - ODBC's list_fields() and field_data() methods skipped the first column due to odbc_field_*() functions' index starting at 1 instead of 0. - Fixed a bug (#129) - ODBC's num_rows() returned -1 in some cases, due to not all subdrivers supporting the odbc_num_rows() function. - Fixed a bug (#153) - E_NOTICE being generated by getimagesize() in the :doc:`File Uploading Library `. -- Fixed a bug (#611) - SQLSRV's _error_message() and _error_number() methods used to issue warnings when there's no actual error. +- Fixed a bug (#611) - SQLSRV's error handling methods used to issue warnings when there's no actual error. - Fixed a bug (#1036) - is_write_type() method in the :doc:`Database Library ` didn't return TRUE for RENAME and OPTIMIZE queries. - Fixed a bug in PDO's _version() method where it used to return the client version as opposed to the server one. - Fixed a bug in PDO's insert_id() method where it could've failed if it's used with Postgre versions prior to 8.1. - Fixed a bug in CUBRID's affected_rows() method where a connection resource was passed to cubrid_affected_rows() instead of a result. - Fixed a bug (#638) - db_set_charset() ignored its arguments and always used the configured charset and collation instead. -- Fixed a bug (#413) - Oracle's _error_message() and _error_number() methods used to only return connection-related errors. +- Fixed a bug (#413) - Oracle's error handling methods used to only return connection-related errors. - Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in warnings being issued by htmlspecialchars(). - Fixed a bug (#1101) - MySQL/MySQLi result method field_data() was implemented as if it was handling a DESCRIBE result instead of the actual result set. - Fixed a bug in Oracle's :doc:`Database Forge Class ` method _create_table() where it failed with AUTO_INCREMENT as it's not supported. diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index 971d5d61d..15a73614a 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -112,3 +112,20 @@ The secondary benefit of using binds is that the values are automatically escaped, producing safer queries. You don't have to remember to manually escape data; the engine does it automatically for you. + +*************** +Handling Errors +*************** + +$this->db->error(); +=================== + +If you need to get the last error that has occured, the error() method +will return an array containing its code and message. Here's a quick +example:: + + if ( ! $this->db->simple_query('SELECT `example_field` FROM `example_table`')) + { + $error = $this->db->error(); // Has keys 'code' and 'message' + } + -- 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(-) 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(-) 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 c7916c1048f54fcff6427c25fee4f0815d4bcfa5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 2 Mar 2012 11:53:15 -0500 Subject: Removed welcome_message view changes --- application/views/welcome_message.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php index 4d9161aa0..acc36b6d4 100644 --- a/application/views/welcome_message.php +++ b/application/views/welcome_message.php @@ -89,8 +89,6 @@ margin: 10px; border: 1px solid #D0D0D0; -webkit-box-shadow: 0 0 8px #D0D0D0; - -moz-box-shadow: 0 0 8px #D0D0D0; - box-shadow: 0 0 8px #D0D0D0; } -- 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(-) 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(-) 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 92aeaaa6b56cd02908641b4ee481a0c246874f29 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 2 Mar 2012 12:18:11 -0500 Subject: Updated changelog --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 69d7efc6c..9a7fc814c 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -78,6 +78,7 @@ Release Date: Not Released - Removed SHA1 function in the :doc:`Encryption Library `. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. - Added function error_array() to return all error messages as an array in the Form_validation class. + - Changed the Session library to select only one row when using database sessions. - Core -- 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 +- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 69d7efc6c..1eae6fea0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -128,6 +128,7 @@ Bug fixes for 3.0 - Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in warnings being issued by htmlspecialchars(). - Fixed a bug (#1101) - MySQL/MySQLi result method field_data() was implemented as if it was handling a DESCRIBE result instead of the actual result set. - Fixed a bug in Oracle's :doc:`Database Forge Class ` method _create_table() where it failed with AUTO_INCREMENT as it's not supported. +- Fixed a bug (#1080) - When using the SMTP protocol, the :doc:`Email Library ` send() method was returning TRUE even if the connection/authentication against the server failed. Version 2.1.1 ============= -- 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(-) 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 +++++++---- user_guide_src/source/changelog.rst | 2 + 14 files changed, 111 insertions(+), 87 deletions(-) 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']; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f00021cd9..ca36ecd31 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -57,6 +57,8 @@ Release Date: Not Released - Added Interbase/Firebird database support via the "interbase" driver - Added an optional database name parameter to db_select(). - Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message. + - Improved version() implementation so that drivers that have a native function to get the version number don't have to be defined in the core DB_driver class. + - PostgreSQL driver now uses pg_version() to get the database version number, when possible. - Libraries -- 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 +++++++++++++ user_guide_src/source/changelog.rst | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) 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 * diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index ca36ecd31..6f3b030a0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -59,6 +59,7 @@ Release Date: Not Released - Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message. - Improved version() implementation so that drivers that have a native function to get the version number don't have to be defined in the core DB_driver class. - PostgreSQL driver now uses pg_version() to get the database version number, when possible. + - Added db_set_charset() support for PostgreSQL. - Libraries -- 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 ++++++++-------------- user_guide_src/source/changelog.rst | 6 ++-- 3 files changed, 17 insertions(+), 26 deletions(-) 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 */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 6f3b030a0..cb33336a1 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -58,8 +58,10 @@ Release Date: Not Released - Added an optional database name parameter to db_select(). - Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message. - Improved version() implementation so that drivers that have a native function to get the version number don't have to be defined in the core DB_driver class. - - PostgreSQL driver now uses pg_version() to get the database version number, when possible. - - Added db_set_charset() support for PostgreSQL. + - Improved support of the PostgreSQL driver, including: + - pg_version() is now used to get the database version number, when possible. + - Added db_set_charset() support. + - Added _optimize_table() support for the :doc:`Database Utility Class ` (rebuilds table indexes). - Libraries -- 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(-) 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 2f8473c031e8a1fa62a5556e013e293c297c41da Mon Sep 17 00:00:00 2001 From: Brenderous Date: Fri, 2 Mar 2012 20:29:38 -0700 Subject: Just a grammar fix. Changed "...as the code these file contain will be minimized" to "...as the code these files contain will be minimized". --- user_guide_src/source/overview/at_a_glance.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/overview/at_a_glance.rst b/user_guide_src/source/overview/at_a_glance.rst index 31f0b4dd9..6dcfdbb14 100644 --- a/user_guide_src/source/overview/at_a_glance.rst +++ b/user_guide_src/source/overview/at_a_glance.rst @@ -41,7 +41,7 @@ CodeIgniter Uses M-V-C CodeIgniter uses the Model-View-Controller approach, which allows great separation between logic and presentation. This is particularly good for projects in which designers are working with your template files, as the -code these file contain will be minimized. We describe MVC in more +code these files contain will be minimized. We describe MVC in more detail on its own page. CodeIgniter Generates Clean URLs -- 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(-) 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 +++++++-------------------- user_guide/changelog.html | 5 +++++ 2 files changed, 12 insertions(+), 20 deletions(-) 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); } } diff --git a/user_guide/changelog.html b/user_guide/changelog.html index b87e61ba8..b85dc8d52 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -71,6 +71,11 @@ Change Log
  • Further improved MIME type detection in the File Uploading Library.
  • +
  • Helpers +
      +
    • url_title() performance and output improved.
    • +
    +
  • Bug fixes for 2.1.1

    -- 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 +- user_guide/changelog.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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) { diff --git a/user_guide/changelog.html b/user_guide/changelog.html index b87e61ba8..cf693685b 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -78,6 +78,7 @@ Change Log
  • Fixed a bug (#697) - A wrong array key was used in the Upload library to check for mime-types.
  • Fixed a bug - form_open() compared $action against site_url() instead of base_url()
  • Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
  • +
  • Fixed a bug - CI_Upload::_file_mime_type() could've failed if popen() is used for the detection.
  • Fixed a bug (#538) - Windows paths were ignored when using the Image Manipulation Class to create a new file.
  • Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
  • -- cgit v1.2.3-24-g4f1b From 69dcfbc0f45097e5471858e2ef8d6c92096bc1e7 Mon Sep 17 00:00:00 2001 From: tubalmartin Date: Sun, 4 Mar 2012 14:17:52 +0100 Subject: Removed changelog entry --- user_guide/changelog.html | 1 - 1 file changed, 1 deletion(-) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index cf693685b..b87e61ba8 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -78,7 +78,6 @@ Change Log
  • Fixed a bug (#697) - A wrong array key was used in the Upload library to check for mime-types.
  • Fixed a bug - form_open() compared $action against site_url() instead of base_url()
  • Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
  • -
  • Fixed a bug - CI_Upload::_file_mime_type() could've failed if popen() is used for the detection.
  • Fixed a bug (#538) - Windows paths were ignored when using the Image Manipulation Class to create a new file.
  • Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
  • -- 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(-) 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 ++++++++++++++++++---- user_guide_src/source/changelog.rst | 1 + .../source/libraries/form_validation.rst | 35 ++++++++++- 3 files changed, 88 insertions(+), 15 deletions(-) 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 */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2ada9ee67..2158104f9 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -83,6 +83,7 @@ Release Date: Not Released - Removed SHA1 function in the :doc:`Encryption Library `. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. - Added function error_array() to return all error messages as an array in the Form_validation class. + - Added function set_data() to Form_validation library, which can be used in place of the default $_POST array. - Changed the Session library to select only one row when using database sessions. - Core diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 09a192bb0..2fe315dba 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -579,7 +579,27 @@ must supply it as an array to the function. Example:: For more info please see the :ref:`using-arrays-as-field-names` section below. -.. _saving-groups: +Validating An Array (Other Than The $_POST Array) +================================================= + +Sometimes you may want to validate an array that does not originate from $_POST data. + +In this case, you can specify the array to be validated:: + + $data = array( + 'username' => 'johndoe', + 'password' => 'mypassword', + 'passconf' => 'mypassword' + )); + + $this->form_validation->set_data($data); + +Creating validation rules, running the validation and retrieving error messages works the same whether you are +validating $_POST data or an array. + +For more info please see the :ref:`function-reference` section below. + +-.. _saving-groups: ************************************************ Saving Sets of Validation Rules to a Config File @@ -930,6 +950,16 @@ $this->form_validation->set_message(); Permits you to set custom error messages. See :ref:`setting-error-messages` +$this->form_validation->set_data(); +======================================== + + .. php:method:: set_data ($data = '') + + :param array $data: The data to validate + + Permits you to set an array for validation, instead of using the default + $_POST array. + $this->form_validation->error_array(); ======================================== @@ -1019,5 +1049,4 @@ This function is identical to the **set_checkbox()** function above. :: /> - /> - + /> \ No newline at end of file -- 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(-) 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 a67ddc61937d178231607f66f2af3ef729f208d4 Mon Sep 17 00:00:00 2001 From: tubalmartin Date: Sun, 4 Mar 2012 16:18:04 +0100 Subject: User guide updated --- user_guide/helpers/url_helper.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html index 76ec32ab2..c23c5ac92 100644 --- a/user_guide/helpers/url_helper.html +++ b/user_guide/helpers/url_helper.html @@ -231,11 +231,11 @@ $url_title = url_title($title);
    -

    The second parameter determines the word delimiter. By default dashes are used. Options are: dash, or underscore:

    +

    The second parameter determines the word delimiter. By default dashes are used.

    $title = "What's wrong with CSS?";

    -$url_title = url_title($title, 'underscore');
    +$url_title = url_title($title, '_');

    // Produces: Whats_wrong_with_CSS
    @@ -244,7 +244,7 @@ $url_title = url_title($title, 'underscore');
    $title = "What's wrong with CSS?";

    -$url_title = url_title($title, 'underscore', TRUE);
    +$url_title = url_title($title, '_', TRUE);

    // Produces: whats_wrong_with_css
    -- cgit v1.2.3-24-g4f1b From 6f6897cdce965e1cf54deb40ce93ba9be281108f Mon Sep 17 00:00:00 2001 From: tubalmartin Date: Sun, 4 Mar 2012 16:24:04 +0100 Subject: Changelog updated --- user_guide/changelog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/changelog.html b/user_guide/changelog.html index b85dc8d52..613c4e65d 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -73,7 +73,7 @@ Change Log
  • Helpers
      -
    • url_title() performance and output improved.
    • +
    • url_title() performance and output improved. You can now use any string as the word delimiter. Backwards compatible with 'dash' or 'underscore' as words delimiters.
  • -- 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 +++++++++++----------- .../source/libraries/form_validation.rst | 18 ++++---- 2 files changed, 33 insertions(+), 34 deletions(-) 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 */ diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 2fe315dba..0d8218374 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -579,20 +579,20 @@ must supply it as an array to the function. Example:: For more info please see the :ref:`using-arrays-as-field-names` section below. -Validating An Array (Other Than The $_POST Array) -================================================= +Validating an Array (other than $_POST) +======================================= Sometimes you may want to validate an array that does not originate from $_POST data. In this case, you can specify the array to be validated:: - $data = array( - 'username' => 'johndoe', - 'password' => 'mypassword', - 'passconf' => 'mypassword' - )); + $data = array( + 'username' => 'johndoe', + 'password' => 'mypassword', + 'passconf' => 'mypassword' + ); - $this->form_validation->set_data($data); + $this->form_validation->set_data($data); Creating validation rules, running the validation and retrieving error messages works the same whether you are validating $_POST data or an array. @@ -1049,4 +1049,4 @@ This function is identical to the **set_checkbox()** function above. :: /> - /> \ No newline at end of file + /> -- cgit v1.2.3-24-g4f1b From 8af2fdfda32303b8e2766d1fc873d1111baeb57e 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 +++++---- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/libraries/form_validation.rst | 11 +++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) 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(); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e96076164..21675bd16 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -84,6 +84,7 @@ Release Date: Not Released - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. - Added function error_array() to return all error messages as an array in the Form_validation class. - Added function set_data() to Form_validation library, which can be used in place of the default $_POST array. + - Added function reset_validation() to form validation library, which resets internal validation variables in case of multiple validation routines. - Changed the Session library to select only one row when using database sessions. - Core diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 0d6a49e79..5aa64d032 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -597,6 +597,9 @@ In this case, you can specify the array to be validated:: Creating validation rules, running the validation and retrieving error messages works the same whether you are validating $_POST data or an array. +**Important Note:** If you want to validate more than one array during a single execution, then you should +call the reset_validation() function before setting up rules and validating the new array. + For more info please see the :ref:`function-reference` section below. -.. _saving-groups: @@ -966,6 +969,14 @@ $this->form_validation->set_data(); Permits you to set an array for validation, instead of using the default $_POST array. +$this->form_validation->reset_validation(); +======================================== + + .. php:method:: reset_validation () + + Permits you to reset the validation when you validate more than one array. + This function should be called before validating each new array. + $this->form_validation->error_array(); ======================================== -- 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(-) 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 +++---- user_guide_src/source/changelog.rst | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) 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; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 81be64b4d..0de85a46b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -137,6 +137,7 @@ Bug fixes for 3.0 - Fixed a bug in Oracle's :doc:`Database Forge Class ` method _create_table() where it failed with AUTO_INCREMENT as it's not supported. - Fixed a bug (#1080) - When using the SMTP protocol, the :doc:`Email Library ` send() method was returning TRUE even if the connection/authentication against the server failed. - Fixed a bug (#499) - a CSRF cookie was created even with CSRF protection being disabled. +- Fixed a bug (#306) - ODBC's insert_id() method was calling non-existent function odbc_insert_id(), which resulted in a fatal error. Version 2.1.1 ============= -- 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 ++++++++++++--- user_guide_src/source/changelog.rst | 2 ++ 4 files changed, 22 insertions(+), 23 deletions(-) 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. diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0de85a46b..533746065 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -62,6 +62,7 @@ Release Date: Not Released - pg_version() is now used to get the database version number, when possible. - Added db_set_charset() support. - Added _optimize_table() support for the :doc:`Database Utility Class ` (rebuilds table indexes). + - Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction. - Libraries @@ -138,6 +139,7 @@ Bug fixes for 3.0 - Fixed a bug (#1080) - When using the SMTP protocol, the :doc:`Email Library ` send() method was returning TRUE even if the connection/authentication against the server failed. - Fixed a bug (#499) - a CSRF cookie was created even with CSRF protection being disabled. - Fixed a bug (#306) - ODBC's insert_id() method was calling non-existent function odbc_insert_id(), which resulted in a fatal error. +- Fixed a bug in Oracle's DB_result class where the cursor id passed to it was always NULL. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From fdb75418c9c4b87e9d7f15f1b59fe8d55739c8f3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 5 Mar 2012 16:32:17 +0200 Subject: Add a note to the num_rows() documentation --- user_guide_src/source/database/results.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 4f93c794d..90d2efce3 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -150,6 +150,12 @@ is the variable that the query result object is assigned to:: echo $query->num_rows(); +..note:: + Not all database drivers have a native way of getting the total + number of rows for a result set. When this is the case, all of + the data is prefetched and count() is manually called on the + resulting array in order to achieve the same functionality. + $query->num_fields() ===================== @@ -182,5 +188,4 @@ Example:: $row = $query2->row(); echo $row->name; - $query2->free_result();// The $query2 result object will no longer be available - + $query2->free_result(); // The $query2 result object will no longer be available -- cgit v1.2.3-24-g4f1b From 69bb408cefe7ae496353f0d81692699f6ef83353 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 5 Mar 2012 12:49:55 -0500 Subject: Fixed note in documentation --- user_guide_src/source/database/results.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 90d2efce3..865345762 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -150,7 +150,7 @@ is the variable that the query result object is assigned to:: echo $query->num_rows(); -..note:: +.. note:: Not all database drivers have a native way of getting the total number of rows for a result set. When this is the case, all of the data is prefetched and count() is manually called on the -- 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(-) 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 2eee0aaacc1b4aff6e1137954dfe1a09c491cdb6 Mon Sep 17 00:00:00 2001 From: Hamza Bhatti Date: Mon, 5 Mar 2012 23:23:31 +0400 Subject: Add changelog entry (bug fix for issue #64) Signed-off-by: Hamza Bhatti --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 533746065..2f525b10a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -158,6 +158,7 @@ Release Date: Not Released Bug fixes for 2.1.1 ------------------- +- Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. - Fixed a bug (#697) - A wrong array key was used in the Upload library to check for mime-types. - Fixed a bug - form_open() compared $action against site_url() instead of base_url(). - Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE. -- cgit v1.2.3-24-g4f1b From 567474528e0c1a4e305dbe8787b83e526b46eb02 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 5 Mar 2012 19:38:08 +0000 Subject: Moved change log entry from 2.1.1 to 3.0. --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2f525b10a..683dd5516 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -140,6 +140,7 @@ Bug fixes for 3.0 - Fixed a bug (#499) - a CSRF cookie was created even with CSRF protection being disabled. - Fixed a bug (#306) - ODBC's insert_id() method was calling non-existent function odbc_insert_id(), which resulted in a fatal error. - Fixed a bug in Oracle's DB_result class where the cursor id passed to it was always NULL. +- Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. Version 2.1.1 ============= @@ -158,7 +159,6 @@ Release Date: Not Released Bug fixes for 2.1.1 ------------------- -- Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. - Fixed a bug (#697) - A wrong array key was used in the Upload library to check for mime-types. - Fixed a bug - form_open() compared $action against site_url() instead of base_url(). - Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE. -- 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(-) 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(-) 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 92d68cc37dd8644563bfcc7199fec29e89ecc1ba Mon Sep 17 00:00:00 2001 From: SammyK Date: Mon, 5 Mar 2012 17:27:56 -0600 Subject: Updated changelog --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 683dd5516..e376497c9 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -63,6 +63,7 @@ Release Date: Not Released - Added db_set_charset() support. - Added _optimize_table() support for the :doc:`Database Utility Class ` (rebuilds table indexes). - Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction. + - Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features. - Libraries -- 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(+) 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 ++++++---- user_guide_src/source/changelog.rst | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) 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.'); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e376497c9..663e204e1 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -142,6 +142,7 @@ Bug fixes for 3.0 - Fixed a bug (#306) - ODBC's insert_id() method was calling non-existent function odbc_insert_id(), which resulted in a fatal error. - Fixed a bug in Oracle's DB_result class where the cursor id passed to it was always NULL. - Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. +- Fixed a bug in the :doc:`Session Library ` where a PHP E_NOTICE error was triggered by _unserialize() due to results from databases such as MSSQL and Oracle being space-padded on the right. Version 2.1.1 ============= -- 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 +++++---- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/libraries/form_validation.rst | 11 +++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) 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(); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 683dd5516..6c8344248 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -85,6 +85,7 @@ Release Date: Not Released - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. - Added function error_array() to return all error messages as an array in the Form_validation class. - Added function set_data() to Form_validation library, which can be used in place of the default $_POST array. + - Added function reset_validation() to form validation library, which resets internal validation variables in case of multiple validation routines. - Changed the Session library to select only one row when using database sessions. - Core diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 0d6a49e79..5aa64d032 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -597,6 +597,9 @@ In this case, you can specify the array to be validated:: Creating validation rules, running the validation and retrieving error messages works the same whether you are validating $_POST data or an array. +**Important Note:** If you want to validate more than one array during a single execution, then you should +call the reset_validation() function before setting up rules and validating the new array. + For more info please see the :ref:`function-reference` section below. -.. _saving-groups: @@ -966,6 +969,14 @@ $this->form_validation->set_data(); Permits you to set an array for validation, instead of using the default $_POST array. +$this->form_validation->reset_validation(); +======================================== + + .. php:method:: reset_validation () + + Permits you to reset the validation when you validate more than one array. + This function should be called before validating each new array. + $this->form_validation->error_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 +- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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('load->vars(). - is_loaded() function from system/core/Commons.php now returns a reference. + - $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as * 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(-) 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(-) 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(-) 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 ++++--- user_guide_src/source/changelog.rst | 1 + 23 files changed, 124 insertions(+), 162 deletions(-) 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 */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 37016f832..b5fb52df4 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -64,6 +64,7 @@ Release Date: Not Released - Added _optimize_table() support for the :doc:`Database Utility Class ` (rebuilds table indexes). - Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction. - Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features. + - Removed protect_identifiers() and renamed _protect_identifiers() to it instead - it was just an alias. - Libraries -- 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(-) 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(-) 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 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(-) 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 1d571971be8be78a92d31aad27dda4009770043f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 7 Mar 2012 11:49:35 +0200 Subject: Update the example on extending libraries with a constructor --- user_guide_src/source/general/creating_libraries.rst | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/general/creating_libraries.rst b/user_guide_src/source/general/creating_libraries.rst index bc545b483..673fbd4bb 100644 --- a/user_guide_src/source/general/creating_libraries.rst +++ b/user_guide_src/source/general/creating_libraries.rst @@ -188,17 +188,23 @@ application/libraries/MY_Email.php, and declare your class with:: } -Note: If you need to use a constructor in your class make sure you +If you need to use a constructor in your class make sure you extend the parent constructor:: class MY_Email extends CI_Email { - public function __construct() - { - parent::__construct(); - } + public function __construct($config = array()) + { + parent::__construct($config); + } + } +.. note:: + Not all of the libraries have the same (or any) parameters + in their constructor. Take a look at the library that you're + extending first to see how it should be implemented. + Loading Your Sub-class ---------------------- -- 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 +++++++++++++++++++++++++++++ user_guide_src/source/changelog.rst | 2 ++ user_guide_src/source/libraries/input.rst | 31 ++++++++++++++++++++++++++++--- 3 files changed, 59 insertions(+), 3 deletions(-) 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 */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index b5fb52df4..f8c4ba144 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -97,6 +97,8 @@ Release Date: Not Released - Added method get_vars() to CI_Loader to retrieve all variables loaded with $this->load->vars(). - is_loaded() function from system/core/Commons.php now returns a reference. - $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as *input->post(NULL, TRUE); // returns all POST items with XSS filter + $this->input->post(NULL, TRUE); // returns all POST items with XSS filter $this->input->post(); // returns all POST items without XSS filter $this->input->get() @@ -119,9 +119,9 @@ The function returns FALSE (boolean) if there are no items in the GET. :: - $this->input->get(NULL, TRUE); // returns all GET items with XSS filter + $this->input->get(NULL, TRUE); // returns all GET items with XSS filter $this->input->get(); // returns all GET items without XSS filtering - + $this->input->get_post() ========================= @@ -298,3 +298,28 @@ see if PHP is being run on the command line. $this->input->is_cli_request() +$this->input->method(); +===================================== + +Returns the $_SERVER['REQUEST_METHOD'] in lowercase. + +:: + + $this->input->method(); + +$this->input->is_method($method); +===================================== + +Returns TRUE if given method equals $_SERVER['REQUEST_METHOD'], otherwise returns FALSE. + +:: + + if ( ! $this->input->is_method('post')) + { + echo 'This is NOT a POST request'; + } + else + { + echo 'This is a POST request'; + } + -- 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 ++++++------------------ user_guide_src/source/changelog.rst | 3 +-- user_guide_src/source/libraries/input.rst | 23 ++++------------------- 3 files changed, 11 insertions(+), 39 deletions(-) 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')); } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f8c4ba144..58a4cb76b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -97,8 +97,7 @@ Release Date: Not Released - Added method get_vars() to CI_Loader to retrieve all variables loaded with $this->load->vars(). - is_loaded() function from system/core/Commons.php now returns a reference. - $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as *input->method(); ===================================== -Returns the $_SERVER['REQUEST_METHOD'] in lowercase. +Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (standard lowercase). :: - $this->input->method(); - -$this->input->is_method($method); -===================================== - -Returns TRUE if given method equals $_SERVER['REQUEST_METHOD'], otherwise returns FALSE. - -:: - - if ( ! $this->input->is_method('post')) - { - echo 'This is NOT a POST request'; - } - else - { - echo 'This is a POST request'; - } - + echo $this->input->method(TRUE); // Outputs: POST + echo $this->input->method(FALSE); // Outputs: post + echo $this->input->method(); // Outputs: post -- 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(-) 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(-) 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 1e9fb49a9eb5cebbe2e3cdf106892d9af72cfdc5 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 7 Mar 2012 20:51:25 +0100 Subject: userguide fix --- user_guide_src/source/libraries/input.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index c63c627db..1f2ea650a 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -301,7 +301,7 @@ see if PHP is being run on the command line. $this->input->method(); ===================================== -Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (standard lowercase). +Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (default lowercase). :: -- 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(-) 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 +++++++++----------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) 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() { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 58a4cb76b..4c6fd38bc 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -147,6 +147,7 @@ Bug fixes for 3.0 - Fixed a bug in Oracle's DB_result class where the cursor id passed to it was always NULL. - Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. - Fixed a bug in the :doc:`Session Library ` where a PHP E_NOTICE error was triggered by _unserialize() due to results from databases such as MSSQL and Oracle being space-padded on the right. +- Fixed a bug (#501) - set_rules() to check if the request method is not 'POST' before aborting, instead of depending on count($_POST) in the :doc:`Form Validation Library `. Version 2.1.1 ============= -- 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(-) 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 ++-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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(); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4c6fd38bc..587c64c5a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -148,6 +148,7 @@ Bug fixes for 3.0 - Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. - Fixed a bug in the :doc:`Session Library ` where a PHP E_NOTICE error was triggered by _unserialize() due to results from databases such as MSSQL and Oracle being space-padded on the right. - Fixed a bug (#501) - set_rules() to check if the request method is not 'POST' before aborting, instead of depending on count($_POST) in the :doc:`Form Validation Library `. +- Fixed a bug (#940) - csrf_verify() used to set the CSRF cookie while processing a POST request with no actual POST data, which resulted in validating a request that should be considered invalid. Version 2.1.1 ============= -- 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(-) 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 c016a1102e2a77e0c27b9656c19a0460df24dfb6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Mar 2012 00:13:42 +0200 Subject: Fix documentation entry for the decimal form validation rule (issue #1149) --- user_guide_src/source/libraries/form_validation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 5aa64d032..39b389f09 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -869,7 +869,7 @@ Rule Parameter Description underscores or dashes. **numeric** No Returns FALSE if the form element contains anything other than numeric characters. **integer** No Returns FALSE if the form element contains anything other than an integer. -**decimal** Yes Returns FALSE if the form element is not exactly the parameter value. +**decimal** No Returns FALSE if the form element contains anything other than a decimal number. **is_natural** No Returns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc. **is_natural_no_zero** No Returns FALSE if the form element contains anything other than a natural -- 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... --- application/config/autoload.php | 2 +- application/config/config.php | 2 +- application/config/constants.php | 2 +- application/config/database.php | 2 +- application/config/doctypes.php | 2 +- application/config/foreign_chars.php | 2 +- application/config/hooks.php | 2 +- application/config/memcached.php | 2 +- application/config/migration.php | 2 +- application/config/mimes.php | 2 +- application/config/profiler.php | 2 +- application/config/routes.php | 2 +- application/config/smileys.php | 2 +- application/config/user_agents.php | 2 +- application/controllers/welcome.php | 2 +- application/errors/error_404.php | 2 +- application/errors/error_db.php | 2 +- application/errors/error_general.php | 2 +- application/errors/error_php.php | 2 +- application/views/welcome_message.php | 2 +- index.php | 2 +- readme.rst | 8 ++++---- 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 +- user_guide_src/cilexer/cilexer/cilexer.py | 2 +- user_guide_src/source/_themes/eldocs/static/asset/css/common.css | 2 +- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/general/requirements.rst | 4 ++-- user_guide_src/source/installation/upgrade_200.rst | 2 +- 157 files changed, 161 insertions(+), 160 deletions(-) diff --git a/application/config/autoload.php b/application/config/autoload.php index db49ca109..e8c999334 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.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/application/config/config.php b/application/config/config.php index 17b854b29..4ad9d1d6a 100644 --- a/application/config/config.php +++ b/application/config/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/application/config/constants.php b/application/config/constants.php index c7203e47d..fce101320 100644 --- a/application/config/constants.php +++ b/application/config/constants.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/application/config/database.php b/application/config/database.php index bd68db1d8..154638d1f 100644 --- a/application/config/database.php +++ b/application/config/database.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/application/config/doctypes.php b/application/config/doctypes.php index 984da5965..e5e70daf6 100644 --- a/application/config/doctypes.php +++ b/application/config/doctypes.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/application/config/foreign_chars.php b/application/config/foreign_chars.php index 1ae0cef5f..d3713fe98 100644 --- a/application/config/foreign_chars.php +++ b/application/config/foreign_chars.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/application/config/hooks.php b/application/config/hooks.php index 80269df59..1b10fc27d 100644 --- a/application/config/hooks.php +++ b/application/config/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/application/config/memcached.php b/application/config/memcached.php index 2b1a77266..7166b70ba 100644 --- a/application/config/memcached.php +++ b/application/config/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/application/config/migration.php b/application/config/migration.php index 668c35740..e1ce1ae6f 100644 --- a/application/config/migration.php +++ b/application/config/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/application/config/mimes.php b/application/config/mimes.php index d69497a30..7ec782b60 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.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/application/config/profiler.php b/application/config/profiler.php index f95614241..53391892d 100644 --- a/application/config/profiler.php +++ b/application/config/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/application/config/routes.php b/application/config/routes.php index 53fc7e799..686573deb 100644 --- a/application/config/routes.php +++ b/application/config/routes.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/application/config/smileys.php b/application/config/smileys.php index 4132aed2f..8e3844a89 100644 --- a/application/config/smileys.php +++ b/application/config/smileys.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/application/config/user_agents.php b/application/config/user_agents.php index e7a689402..0baa25220 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.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/application/controllers/welcome.php b/application/controllers/welcome.php index 5eb0e9625..2451d9776 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.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/application/errors/error_404.php b/application/errors/error_404.php index 4dd8fc407..9af9e39de 100644 --- a/application/errors/error_404.php +++ b/application/errors/error_404.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/application/errors/error_db.php b/application/errors/error_db.php index 130ffc11d..81ff02adb 100644 --- a/application/errors/error_db.php +++ b/application/errors/error_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/application/errors/error_general.php b/application/errors/error_general.php index 2a844a8e2..8efcfd991 100644 --- a/application/errors/error_general.php +++ b/application/errors/error_general.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/application/errors/error_php.php b/application/errors/error_php.php index 8e293cd5e..42e5f5a28 100644 --- a/application/errors/error_php.php +++ b/application/errors/error_php.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/application/views/welcome_message.php b/application/views/welcome_message.php index acc36b6d4..0dd892441 100644 --- a/application/views/welcome_message.php +++ b/application/views/welcome_message.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/index.php b/index.php index a37826690..5a1190112 100644 --- a/index.php +++ b/index.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/readme.rst b/readme.rst index 2369a8ddb..4707847c7 100644 --- a/readme.rst +++ b/readme.rst @@ -29,7 +29,7 @@ guide change log `_ version 5.1.6 or newer. +- `PHP `_ version 5.2.4 or newer. - A Database is required for most web application programming. Current - supported databases are MySQL (4.1+), MySQLi, MS SQL, Postgres, Oracle, + supported databases are MySQL (5.1+), MySQLi, MS SQL, Postgres, Oracle, SQLite, ODBC and CUBRID. \ No newline at end of file diff --git a/user_guide_src/source/installation/upgrade_200.rst b/user_guide_src/source/installation/upgrade_200.rst index 0bcbd5c99..b39f4fd23 100644 --- a/user_guide_src/source/installation/upgrade_200.rst +++ b/user_guide_src/source/installation/upgrade_200.rst @@ -102,7 +102,7 @@ Please refer to the :ref:`2.0.0 Change Log <2.0.0-changelog>` for full details, but here are some of the larger changes that are more likely to impact your code: -- CodeIgniter now requires PHP 5.1.6. +- CodeIgniter now requires PHP 5.2.4. - Scaffolding has been removed. - The CAPTCHA plugin in now a :doc:`helper `. - The JavaScript calendar plugin was removed. -- 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(-) 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(-) 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(-) 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 02197502bb507022d7740d9f38d1a670ba16c96b Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sat, 10 Mar 2012 16:39:50 +0700 Subject: Travis setup --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..7f290e6be --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: php + +phps: + - 5.2 + - 5.3 + - 5.4 + +branches: + except: + - develop + - master -- 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(-) 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 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(-) 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 +--- user_guide_src/source/changelog.rst | 2 +- 3 files changed, 3 insertions(+), 34 deletions(-) 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)); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index aee992e67..8579218b0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -71,7 +71,6 @@ Release Date: Not Released - Added max_filename_increment config setting for Upload library. - CI_Loader::_ci_autoloader() is now a protected method. - - Modified valid_ip() to use PHP's filter_var() when possible (>= PHP 5.2) in the :doc:`Form Validation library `. - Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname) - Cart library changes include: - It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites. @@ -99,6 +98,7 @@ Release Date: Not Released - is_loaded() function from system/core/Commons.php now returns a reference. - $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as *`. Bug fixes for 3.0 ------------------ -- 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(-) 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(-) 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 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 +++++++++++++++++++------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) 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.'"'); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8579218b0..139899af0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -43,6 +43,7 @@ Release Date: Not Released - Changed humanize to include a second param for the separator. - Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words. - Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default). + - Added a work-around in force_download() for a bug Android <= 2.1, where the filename extension needs to be in uppercase. - Database -- 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(-) 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 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 +++++++++++++++++ user_guide_src/source/changelog.rst | 1 + 2 files changed, 18 insertions(+) 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); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 139899af0..f462e1b11 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -44,6 +44,7 @@ Release Date: Not Released - Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words. - Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default). - Added a work-around in force_download() for a bug Android <= 2.1, where the filename extension needs to be in uppercase. + - form_dropdown() will now also take an array for unity with other form helpers. - Database -- 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 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(-) 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(-) 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 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(-) 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 +-- user_guide_src/source/changelog.rst | 4 +++- 4 files changed, 8 insertions(+), 8 deletions(-) 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); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2ea810d30..1c9e1992d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -68,6 +68,8 @@ Release Date: Not Released - Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction. - Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features. - Removed protect_identifiers() and renamed _protect_identifiers() to it instead - it was just an alias. + - MySQL and MySQLi drivers now require at least MySQL version 5.1. + - db_set_charset() now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1). - Libraries @@ -140,7 +142,7 @@ Bug fixes for 3.0 - Fixed a bug in PDO's _version() method where it used to return the client version as opposed to the server one. - Fixed a bug in PDO's insert_id() method where it could've failed if it's used with Postgre versions prior to 8.1. - Fixed a bug in CUBRID's affected_rows() method where a connection resource was passed to cubrid_affected_rows() instead of a result. -- Fixed a bug (#638) - db_set_charset() ignored its arguments and always used the configured charset and collation instead. +- Fixed a bug (#638) - db_set_charset() ignored its arguments and always used the configured charset instead. - Fixed a bug (#413) - Oracle's error handling methods used to only return connection-related errors. - Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in warnings being issued by htmlspecialchars(). - Fixed a bug (#1101) - MySQL/MySQLi result method field_data() was implemented as if it was handling a DESCRIBE result instead of the actual result set. -- 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(-) 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 2004325337c501b201fe55f653f86d3ba8432d06 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 16:48:28 +0200 Subject: Update the list of supported databases --- user_guide_src/source/general/requirements.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/general/requirements.rst b/user_guide_src/source/general/requirements.rst index a927b7af6..05e87961a 100644 --- a/user_guide_src/source/general/requirements.rst +++ b/user_guide_src/source/general/requirements.rst @@ -4,5 +4,5 @@ Server Requirements - `PHP `_ version 5.2.4 or newer. - A Database is required for most web application programming. Current - supported databases are MySQL (5.1+), MySQLi, MS SQL, Postgres, Oracle, - SQLite, ODBC and CUBRID. \ No newline at end of file + supported databases are MySQL (5.1+), MySQLi, MS SQL, SQLSRV, Oracle, + PostgreSQL, SQLite, CUBRID, Interbase, ODBC and PDO. -- cgit v1.2.3-24-g4f1b From 492aa4207a59bee71390753b1bd25b83f001aae7 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Mon, 12 Mar 2012 16:02:45 +0100 Subject: user guide udate --- user_guide_src/source/helpers/form_helper.rst | 265 +++++++++++++++----------- 1 file changed, 152 insertions(+), 113 deletions(-) diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 3794e0835..95db51d37 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -45,7 +45,7 @@ parameter, like this :: - $attributes = array('class' => 'email', 'id' => 'myform'); + $attributes = array('class' => 'email', 'id' => 'myform'); echo form_open('email/send', $attributes); The above example would create a form similar to this @@ -61,15 +61,15 @@ Hidden fields can be added by passing an associative array to the third paramete :: - $hidden = array('username' => 'Joe', 'member_id' => '234'); + $hidden = array('username' => 'Joe', 'member_id' => '234'); echo form_open('email/send', '', $hidden); The above example would create a form similar to this :: - - + + form_open_multipart() @@ -87,28 +87,67 @@ name/value string to create one field :: - form_hidden('username', 'johndoe'); + form_hidden('username', 'johndoe'); // Would produce: Or you can submit an associative array to create multiple fields :: - $data = array(                - 'name'  => 'John Doe',                - 'email' => 'john@example.com',                - 'url'   => 'http://example.com'              - ); - - echo form_hidden($data); - + $data = array( + 'name'  => 'John Doe', + 'email' => 'john@example.com', + 'url'   => 'http://example.com' + ); + + echo form_hidden($data); + /* - Would produce: - - + Would produce: + + */ +Or pass an associative array to the values field. + +:: + + $data = array( + 'name'  => 'John Doe', + 'email' => 'john@example.com', + 'url'   => 'http://example.com' + ); + + echo form_hidden('my_array', $data); + + /* + Would produce: + + + + */ + +If you want to create hidden input fields with extra attributes + +:: + + $data = array( + 'type'        => 'hidden', + 'name' => 'email' + 'id'          => 'hiddenemail', + 'value'       => 'john@example.com', + 'class'       => 'hiddenemail' + ); + + echo form_input($data); + + /* + Would produce: + + + */ + form_input() ============ @@ -124,20 +163,20 @@ form to contain :: - $data = array(                - 'name'        => 'username',                - 'id'          => 'username',                - 'value'       => 'johndoe',                - 'maxlength'   => '100',                - 'size'        => '50',                - 'style'       => 'width:50%',              - ); - + $data = array( + 'name'        => 'username', + 'id'          => 'username', + 'value'       => 'johndoe', + 'maxlength'   => '100', + 'size'        => '50', + 'style'       => 'width:50%' + ); + echo form_input($data); - + /* Would produce: - + */ @@ -146,7 +185,7 @@ Javascript, you can pass it as a string in the third parameter :: - $js = 'onClick="some_function()"'; + $js = 'onClick="some_function()"'; echo form_input('username', 'johndoe', $js); form_password() @@ -176,37 +215,37 @@ multiple select for you. Example :: - $options = array(                    - 'small'  => 'Small Shirt',                    - 'med'    => 'Medium Shirt',                    - 'large'   => 'Large Shirt',                    - 'xlarge' => 'Extra Large Shirt',                  - ); - - $shirts_on_sale = array('small', 'large'); - echo form_dropdown('shirts', $options, 'large'); - + $options = array( + 'small'  => 'Small Shirt', + 'med'    => 'Medium Shirt', + 'large'   => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', + ); + + $shirts_on_sale = array('small', 'large'); + echo form_dropdown('shirts', $options, 'large'); + /* - Would produce: - - + + + + */ - + echo form_dropdown('shirts', $options, $shirts_on_sale); - + /* - Would produce: - - + + + + */ @@ -216,7 +255,7 @@ parameter :: - $js = 'id="shirts" onChange="some_function();"'; + $js = 'id="shirts" onChange="some_function();"'; echo form_dropdown('shirts', $options, 'large', $js); If the array passed as $options is a multidimensional array, @@ -240,38 +279,38 @@ Lets you generate fieldset/legend fields. :: - echo form_fieldset('Address Information'); - echo "

    fieldset content here

    \n"; + echo form_fieldset('Address Information'); + echo "

    fieldset content here

    \n"; echo form_fieldset_close(); - + /* Produces: -
    - Address Information -

    form content here

    +
    + Address Information +

    form content here

    */ - + Similar to other functions, you can submit an associative array in the second parameter if you prefer to set additional attributes. :: $attributes = array( - 'id' => 'address_info', + 'id' => 'address_info', 'class' => 'address_info' - ); - - echo form_fieldset('Address Information', $attributes); - echo "

    fieldset content here

    \n"; - echo form_fieldset_close(); - + ); + + echo form_fieldset('Address Information', $attributes); + echo "

    fieldset content here

    \n"; + echo form_fieldset_close(); + /* - Produces: - -
    - Address Information -

    form content here

    + Produces: + +
    + Address Information +

    form content here

    */ @@ -284,8 +323,8 @@ the tag. For example :: - $string = ""; - echo form_fieldset_close($string); + $string = ""; + echo form_fieldset_close($string); // Would produce:
    form_checkbox() @@ -295,7 +334,7 @@ Lets you generate a checkbox field. Simple example :: - echo form_checkbox('newsletter', 'accept', TRUE); + echo form_checkbox('newsletter', 'accept', TRUE); // Would produce: The third parameter contains a boolean TRUE/FALSE to determine whether @@ -306,15 +345,15 @@ array of attributes to the function :: - $data = array(      - 'name'        => 'newsletter',      - 'id'          => 'newsletter',      - 'value'       => 'accept',      - 'checked'     => TRUE,      - 'style'       => 'margin:10px',      - ); - - echo form_checkbox($data); + $data = array( + 'name'        => 'newsletter', + 'id'          => 'newsletter', + 'value'       => 'accept', + 'checked'     => TRUE, + 'style'       => 'margin:10px', + ); + + echo form_checkbox($data); // Would produce: As with other functions, if you would like the tag to contain additional @@ -323,7 +362,7 @@ parameter :: - $js = 'onClick="some_function()"'; + $js = 'onClick="some_function()"'; echo form_checkbox('newsletter', 'accept', TRUE, $js) form_radio() @@ -339,7 +378,7 @@ Lets you generate a standard submit button. Simple example :: - echo form_submit('mysubmit', 'Submit Post!'); + echo form_submit('mysubmit', 'Submit Post!'); // Would produce: Similar to other functions, you can submit an associative array in the @@ -353,7 +392,7 @@ Lets you generate a