diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/drivers/DB_active_record.php | 4 | ||||
-rw-r--r-- | system/drivers/DB_driver.php | 107 | ||||
-rw-r--r-- | system/drivers/DB_mssql.php | 2 | ||||
-rw-r--r-- | system/drivers/DB_mysql.php | 2 | ||||
-rw-r--r-- | system/drivers/DB_mysqli.php | 2 | ||||
-rw-r--r-- | system/drivers/DB_odbc.php | 2 | ||||
-rw-r--r-- | system/drivers/DB_postgre.php | 2 | ||||
-rw-r--r-- | system/drivers/DB_sqlite.php | 2 | ||||
-rw-r--r-- | system/libraries/Validation.php | 18 |
9 files changed, 65 insertions, 76 deletions
diff --git a/system/drivers/DB_active_record.php b/system/drivers/DB_active_record.php index 1320af9ed..c7e4f096c 100644 --- a/system/drivers/DB_active_record.php +++ b/system/drivers/DB_active_record.php @@ -257,7 +257,7 @@ class CI_DB_active_record extends CI_DB_driver { /** * Like * - * Called by like() or olike() + * Called by like() or orlike() * * @access private * @param mixed @@ -346,7 +346,7 @@ class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- /** - * Sets the OR HAVING value + * Sets the HAVING values * * Called by having() or orhaving() * diff --git a/system/drivers/DB_driver.php b/system/drivers/DB_driver.php index 5fcb04a00..2d1232d7b 100644 --- a/system/drivers/DB_driver.php +++ b/system/drivers/DB_driver.php @@ -46,6 +46,12 @@ class CI_DB_driver { var $bind_marker = '?'; var $queries = array(); + // These are use with Oracle + var $stmt_id; + var $curs_id; + var $limit_used; + + /** * Constructor. Accepts one parameter containing the database * connection settings. @@ -151,6 +157,11 @@ class CI_DB_driver { } return FALSE; } + + if ($this->dbdriver == 'oci8') + { + return $sql; + } $query = $this->query($sql); $row = $query->row(); @@ -173,7 +184,7 @@ class CI_DB_driver { * @param array An array of binding data * @return mixed */ - function query($sql, $binds = FALSE) + function query($sql, $binds = FALSE, $return_object = TRUE) { if ( ! $this->conn_id) { @@ -228,11 +239,19 @@ class CI_DB_driver { $this->query_count++; // Was the query a "write" type? - // If so we'll return simply return true + // If so we'll simply return true if ($this->is_write_type($sql) === TRUE) { return TRUE; } + + // Return TRUE if we don't need to create a result object + // Currently only the Oracle driver uses this when stored + // procedures are used + if ($return_object !== TRUE) + { + return TRUE; + } // Instantiate and return the DB result object $result = 'CI_DB_'.$this->dbdriver.'_result'; @@ -241,6 +260,13 @@ class CI_DB_driver { $RES->conn_id = $this->conn_id; $RES->db_debug = $this->db_debug; $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; + } return $RES; } @@ -352,19 +378,16 @@ class CI_DB_driver { */ function escape($str) { - if ( ! is_numeric($str)) // bug fix to ensure that numbers are not treated as strings. - { - switch (gettype($str)) - { - case 'string' : $str = "'".$this->escape_str($str)."'"; - break; - case 'boolean' : $str = ($str === FALSE) ? 0 : 1; - break; - default : $str = ($str === NULL) ? 'NULL' : $str; - break; - } - } - + switch (gettype($str)) + { + case 'string' : $str = "'".$this->escape_str($str)."'"; + break; + case 'boolean' : $str = ($str === FALSE) ? 0 : 1; + break; + default : $str = ($str === NULL) ? 'NULL' : $str; + break; + } + return $str; } @@ -394,7 +417,14 @@ class CI_DB_driver { { foreach($query->result_array() as $row) { - $retval[] = array_shift($row); + if (isset($row['TABLE_NAME'])) + { + $retval[] = $row['TABLE_NAME']; + } + else + { + $retval[] = array_shift($row); + } } } @@ -447,7 +477,7 @@ class CI_DB_driver { $retval = array(); foreach($query->result_array() as $row) { - if ($this->dbdriver == 'mssql' AND isset($row['COLUMN_NAME'])) + if (isset($row['COLUMN_NAME'])) { $retval[] = $row['COLUMN_NAME']; } @@ -671,29 +701,6 @@ class CI_DB_driver { } - // -------------------------------------------------------------------- - - /** - * Field Data - old version - DEPRECATED - * - * @deprecated use $this->db->field_data() instead - */ - function fields($table = '') - { - return $this->field_data($table); - } - - // -------------------------------------------------------------------- - - /** - * Smart Escape String - old version - DEPRECATED - * - * @deprecated use $this->db->escape() instead - */ - function smart_escape_str($str) - { - return $this->escape($str); - } } @@ -926,24 +933,4 @@ class CI_DB_result { } - - -/** - * Database Field Class - * - * This class will contain the field meta-data. It - * is called by one of the field result functions - * - * @category Database - * @author Rick Ellis - * @link http://www.codeigniter.com/user_guide/libraries/database/ - */ -class CI_DB_field { - var $name; - var $type; - var $default; - var $max_length; - var $primary_key; -} - ?>
\ No newline at end of file diff --git a/system/drivers/DB_mssql.php b/system/drivers/DB_mssql.php index f6e672b94..c84247641 100644 --- a/system/drivers/DB_mssql.php +++ b/system/drivers/DB_mssql.php @@ -424,7 +424,7 @@ class CI_DB_mssql_result extends CI_DB_result { $retval = array(); while ($field = mssql_fetch_field($this->result_id)) { - $F = new CI_DB_field(); + $F = new stdClass(); $F->name = $field->name; $F->type = $field->type; $F->max_length = $field->max_length; diff --git a/system/drivers/DB_mysql.php b/system/drivers/DB_mysql.php index a90d84268..72790976e 100644 --- a/system/drivers/DB_mysql.php +++ b/system/drivers/DB_mysql.php @@ -443,7 +443,7 @@ class CI_DB_mysql_result extends CI_DB_result { $retval = array(); while ($field = mysql_fetch_field($this->result_id)) { - $F = new CI_DB_field(); + $F = new stdClass(); $F->name = $field->name; $F->type = $field->type; $F->default = $field->def; diff --git a/system/drivers/DB_mysqli.php b/system/drivers/DB_mysqli.php index 49adb5cc3..d2a3140c2 100644 --- a/system/drivers/DB_mysqli.php +++ b/system/drivers/DB_mysqli.php @@ -451,7 +451,7 @@ class CI_DB_mysqli_result extends CI_DB_result { $retval = array(); while ($field = mysqli_fetch_field($this->result_id)) { - $F = new CI_DB_field(); + $F = new stdClass(); $F->name = $field->name; $F->type = $field->type; $F->default = $field->def; diff --git a/system/drivers/DB_odbc.php b/system/drivers/DB_odbc.php index a5a8db64d..57cdbced8 100644 --- a/system/drivers/DB_odbc.php +++ b/system/drivers/DB_odbc.php @@ -420,7 +420,7 @@ class CI_DB_odbc_result extends CI_DB_result { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) { - $F = new CI_DB_field(); + $F = new stdClass(); $F->name = odbc_field_name($this->result_id, $i); $F->type = odbc_field_type($this->result_id, $i); $F->max_length = odbc_field_len($this->result_id, $i); diff --git a/system/drivers/DB_postgre.php b/system/drivers/DB_postgre.php index aa7ec7020..57ef179d9 100644 --- a/system/drivers/DB_postgre.php +++ b/system/drivers/DB_postgre.php @@ -456,7 +456,7 @@ class CI_DB_postgre_result extends CI_DB_result { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) { - $F = new CI_DB_field(); + $F = new stdClass(); $F->name = pg_field_name($this->result_id, $i); $F->type = pg_field_type($this->result_id, $i); $F->max_length = pg_field_size($this->result_id, $i); diff --git a/system/drivers/DB_sqlite.php b/system/drivers/DB_sqlite.php index 71d2561dc..48e2c8714 100644 --- a/system/drivers/DB_sqlite.php +++ b/system/drivers/DB_sqlite.php @@ -449,7 +449,7 @@ class CI_DB_sqlite_result extends CI_DB_result { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) { - $F = new CI_DB_field(); + $F = new stdClass(); $F->name = sqlite_field_name($this->result_id, $i); $F->type = 'varchar'; $F->max_length = 0; diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php index 227cf9f9a..065e7a2d5 100644 --- a/system/libraries/Validation.php +++ b/system/libraries/Validation.php @@ -246,8 +246,8 @@ class CI_Validation { { $rule = substr($rule, 9); $callback = TRUE; - } - + } + // Strip the parameter (if exists) from the rule // Rules can contain a parameter: max_length[5] $param = FALSE; @@ -265,13 +265,14 @@ class CI_Validation { continue; } - $result = $this->obj->$rule($_POST[$field], $param); + $result = $this->obj->$rule($_POST[$field], $param); - // If the field isn't requires we'll move on... - if ( ! in_array('required', $ex)) + // If the field isn't required and we just processed a callback we'll move on... + if ( ! in_array('required', $ex) AND $result !== FALSE) { - continue; + continue 2; } + } else { @@ -295,7 +296,7 @@ class CI_Validation { $result = $this->$rule($_POST[$field], $param); } - + // Did the rule test negatively? If so, grab the error. if ($result === FALSE) { @@ -323,8 +324,9 @@ class CI_Validation { // Add the error to the error array $this->_error_array[] = $message; continue 2; - } + } } + } $total_errors = count($this->_error_array); |