From 76e0435af10579afdc3ed4956aeafa83a17decd3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 11:55:17 -0500 Subject: First iteration of interbase driver --- system/database/drivers/interbase/index.html | 10 + .../drivers/interbase/interbase_driver.php | 676 +++++++++++++++++++++ .../database/drivers/interbase/interbase_forge.php | 262 ++++++++ .../drivers/interbase/interbase_result.php | 190 ++++++ .../drivers/interbase/interbase_utility.php | 108 ++++ 5 files changed, 1246 insertions(+) create mode 100644 system/database/drivers/interbase/index.html create mode 100644 system/database/drivers/interbase/interbase_driver.php create mode 100644 system/database/drivers/interbase/interbase_forge.php create mode 100644 system/database/drivers/interbase/interbase_result.php create mode 100644 system/database/drivers/interbase/interbase_utility.php (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/index.html b/system/database/drivers/interbase/index.html new file mode 100644 index 000000000..c942a79ce --- /dev/null +++ b/system/database/drivers/interbase/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php new file mode 100644 index 000000000..bc9cb8f08 --- /dev/null +++ b/system/database/drivers/interbase/interbase_driver.php @@ -0,0 +1,676 @@ +database, $this->username, $this->password, $this->charset)) + { + log_message('error', $error); + + if ($this->db_debug) + { + $this->display_error($error, '', TRUE); + } + + return FALSE; + } + + return $conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Persistent database connection + * + * @access private called by the base class + * @return resource + */ + function db_pconnect() + { + if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->charset)) + { + log_message('error', $error); + + if ($this->db_debug) + { + $this->display_error($error, '', TRUE); + } + + return FALSE; + } + + return $conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @access public + * @return void + */ + function reconnect() + { + // not implemented in Interbase/Firebird + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @access private called by the base class + * @return resource + */ + function db_select() + { + // Connection selects the database + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @access public + * @param string + * @param string + * @return resource + */ + function db_set_charset($charset, $collation) + { + // @todo - add support if needed + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @access public + * @return string + */ + function _version() + { + //@todo - add support if needed + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @access private called by the base class + * @param string an SQL query + * @return resource + */ + function _execute($sql) + { + $sql = $this->_prep_query($sql); + return @ibase_query($this->conn_id, $sql); + } + + // -------------------------------------------------------------------- + + /** + * Prep the query + * + * If needed, each database adapter can prep the query string + * + * @access private called by execute() + * @param string an SQL query + * @return string + */ + function _prep_query($sql) + { + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @access public + * @return bool + */ + function trans_begin($test_mode = FALSE) + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + + $this->trans = @ibase_trans($this->conn_id); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @access public + * @return bool + */ + function trans_commit() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + @ibase_commit($this->trans); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @access public + * @return bool + */ + function trans_rollback() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + @ibase_rollback($this->trans); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Escape String + * + * @access public + * @param string + * @param bool whether or not the string will be used in a LIKE condition + * @return string + */ + function escape_str($str, $like = FALSE) + { + if (is_array($str)) + { + foreach ($str as $key => $val) + { + $str[$key] = $this->escape_str($val, $like); + } + + return $str; + } + + // escape LIKE condition wildcards + if ($like === TRUE) + { + $str = str_replace( array('%', '_', $this->_like_escape_chr), + array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), + $str); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @access public + * @return integer + */ + function affected_rows() + { + return @ibase_affected_rows($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @access public + * @return integer + */ + function insert_id() + { + //@todo Implement manually + return 0; + } + + // -------------------------------------------------------------------- + + /** + * "Count All" query + * + * Generates a platform-specific query string that counts all records in + * the specified database + * + * @access public + * @param string + * @return string + */ + function count_all($table = '') + { + if ($table == '') + { + return 0; + } + + $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + + if ($query->num_rows() == 0) + { + return 0; + } + + $row = $query->row(); + $this->_reset_select(); + return (int) $row->numrows; + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @access private + * @param boolean + * @return string + */ + function _list_tables($prefix_limit = FALSE) + { + $sql = <<dbprefix != '') + { + $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @access public + * @param string the table name + * @return string + */ + function _list_columns($table = '') + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Field data query + * + * Generates a platform-specific query so that the column data can be retrieved + * + * @access public + * @param string the table name + * @return object + */ + function _field_data($table) + { + return "SELECT * FROM ".$table." LIMIT 1"; + } + + // -------------------------------------------------------------------- + + /** + * The error message string + * + * @access private + * @return string + */ + function _error_message() + { + return ibase_errmsg(); + } + + // -------------------------------------------------------------------- + + /** + * The error message number + * + * @access private + * @return integer + */ + function _error_number() + { + return ibase_errcode(); + } + + // -------------------------------------------------------------------- + + /** + * Escape the SQL Identifiers + * + * This function escapes column and table names + * + * @access private + * @param string + * @return string + */ + function _escape_identifiers($item) + { + foreach ($this->_reserved_identifiers as $id) + { + if (strpos($item, '.'.$id) !== FALSE) + { + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + } + } + + if (strpos($item, '.') !== FALSE) + { + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + } + else + { + $str = $this->_escape_char.$item.$this->_escape_char; + } + + // remove duplicates if the user already included the escape + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + } + + // -------------------------------------------------------------------- + + /** + * From Tables + * + * This function implicitly groups FROM tables so there is no confusion + * about operator precedence in harmony with SQL standards + * + * @access public + * @param type + * @return type + */ + function _from_tables($tables) + { + if ( ! is_array($tables)) + { + $tables = array($tables); + } + + return '('.implode(', ', $tables).')'; + } + + // -------------------------------------------------------------------- + + /** + * Insert statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert($table, $keys, $values) + { + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @param array the orderby clause + * @param array the limit clause + * @return string + */ + function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + { + foreach ($values as $key => $val) + { + $valstr[] = $key." = ".$val; + } + + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; + + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); + + $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + + $sql .= $orderby.$limit; + + return $sql; + } + + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * If the database does not support the truncate() command + * This function maps to "DELETE FROM table" + * + * @access public + * @param string the table name + * @return string + */ + function _truncate($table) + { + return $this->_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @access public + * @param string the table name + * @param array the where clause + * @param string the limit clause + * @return string + */ + function _delete($table, $where = array(), $like = array(), $limit = FALSE) + { + $conditions = ''; + + if (count($where) > 0 OR count($like) > 0) + { + $conditions = "\nWHERE "; + $conditions .= implode("\n", $this->ar_where); + + if (count($where) > 0 && count($like) > 0) + { + $conditions .= " AND "; + } + $conditions .= implode("\n", $like); + } + + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + + return "DELETE FROM ".$table.$conditions.$limit; + } + + // -------------------------------------------------------------------- + + /** + * Limit string + * + * Generates a platform-specific LIMIT clause + * + * @access public + * @param string the sql query string + * @param integer the number of rows to limit the query to + * @param integer the offset value + * @return string + */ + function _limit($sql, $limit, $offset) + { + if ($offset == 0) + { + $offset = ''; + } + else + { + $offset .= ", "; + } + + return $sql."LIMIT ".$offset.$limit; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @access public + * @param resource + * @return void + */ + function _close($conn_id) + { + @ibase_close($conn_id); + } + + +} + + +/* End of file interbase_driver.php */ +/* Location: ./system/database/drivers/interbase/interbase_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php new file mode 100644 index 000000000..36d980b67 --- /dev/null +++ b/system/database/drivers/interbase/interbase_forge.php @@ -0,0 +1,262 @@ +conn_id); + } + // -------------------------------------------------------------------- + + /** + * Create Table + * + * @access private + * @param string the table name + * @param array the fields + * @param mixed primary key(s) + * @param mixed key(s) + * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @return bool + */ + function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + { + $sql = 'CREATE TABLE '; + + $sql .= $this->db->_escape_identifiers($table)."("; + $current_field_count = 0; + + foreach ($fields as $field=>$attributes) + { + // Numeric field names aren't allowed in databases, so if the key is + // numeric, we know it was assigned by PHP and the developer manually + // entered the field information, so we'll simply add it to the list + if (is_numeric($field)) + { + $sql .= "\n\t$attributes"; + } + else + { + $attributes = array_change_key_case($attributes, CASE_UPPER); + + $sql .= "\n\t".$this->db->_protect_identifiers($field); + + $sql .= ' '.$attributes['TYPE']; + + if (array_key_exists('CONSTRAINT', $attributes)) + { + $sql .= '('.$attributes['CONSTRAINT'].')'; + } + + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) + { + $sql .= ' UNSIGNED'; + } + + if (array_key_exists('DEFAULT', $attributes)) + { + $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; + } + + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) + { + $sql .= ' NULL'; + } + else + { + $sql .= ' NOT NULL'; + } + + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) + { + $sql .= ' AUTO_INCREMENT'; + } + } + + // don't add a comma on the end of the last field + if (++$current_field_count < count($fields)) + { + $sql .= ','; + } + } + + if (count($primary_keys) > 0) + { + $primary_keys = $this->db->_protect_identifiers($primary_keys); + $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; + } + + if (is_array($keys) && count($keys) > 0) + { + foreach ($keys as $key) + { + if (is_array($key)) + { + $key = $this->db->_protect_identifiers($key); + } + else + { + $key = array($this->db->_protect_identifiers($key)); + } + + $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")"; + } + } + + $sql .= "\n)"; + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Drop Table + * + * @access private + * @return bool + */ + function _drop_table($table) + { + if ($this->db->db_debug) + { + return $this->db->display_error('db_unsuported_feature'); + } + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Alter table query + * + * Generates a platform-specific query so that a table can be altered + * Called by add_column(), drop_column(), and column_alter(), + * + * @access private + * @param string the ALTER type (ADD, DROP, CHANGE) + * @param string the column name + * @param string the table name + * @param string the column definition + * @param string the default value + * @param boolean should 'NOT NULL' be added + * @param string the field after which we should add the new field + * @return object + */ + function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + { + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + + // DROP has everything it needs now. + /*if ($alter_type == 'DROP') + { + // SQLite does not support dropping columns + // http://www.sqlite.org/omitted.html + // http://www.sqlite.org/faq.html#q11 + return FALSE; + }*/ + + $sql .= " $column_definition"; + + if ($default_value != '') + { + $sql .= " DEFAULT \"$default_value\""; + } + + if ($null === NULL) + { + $sql .= ' NULL'; + } + else + { + $sql .= ' NOT NULL'; + } + + if ($after_field != '') + { + $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + } + + return $sql; + + } + + // -------------------------------------------------------------------- + + /** + * Rename a table + * + * Generates a platform-specific query so that a table can be renamed + * + * @access private + * @param string the old table name + * @param string the new table name + * @return string + */ + function _rename_table($table_name, $new_table_name) + { + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); + return $sql; + } +} + +/* End of file interbase_forge.php */ +/* Location: ./system/database/drivers/interbase/interbase_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php new file mode 100644 index 000000000..d811fc608 --- /dev/null +++ b/system/database/drivers/interbase/interbase_result.php @@ -0,0 +1,190 @@ +result_id)) + { + $count++; + } + + return $count; + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @access public + * @return integer + */ + function num_fields() + { + return @ibase_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @access public + * @return array + */ + function list_fields() + { + $field_names = array(); + for ($i = 0; $i < $this->num_fields(); $i++) + { + $info = ibase_field_info($this->result_id, $i); + $field_names[] = $info['name']; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @access public + * @return array + */ + function field_data() + { + + $retval = array(); + for ($i = 0; $i < $this->num_fields(); $i++) + { + $info = ibase_field_info($this->result_id, $i); + + $F = new stdClass(); + $F->name = $info['name']; + $F->type = $info['type']; + $F->max_length = $info['length']; + $F->primary_key = 0; + $F->default = ''; + + $retval[] = $F; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return null + */ + function free_result() + { + @ibase_free_result($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero + * + * @access private + * @return array + */ + function _data_seek($n = 0) + { + //Interbase driver doesn't implement a sutable function + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @access private + * @return array + */ + function _fetch_assoc() + { + return @ibase_fetch_assoc($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @access private + * @return object + */ + function _fetch_object() + { + return @ibase_fetch_object($this->result_id); + } + +} + + +/* End of file interbase_result.php */ +/* Location: ./system/database/drivers/interbase/interbase_result.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php new file mode 100644 index 000000000..533a269b2 --- /dev/null +++ b/system/database/drivers/interbase/interbase_utility.php @@ -0,0 +1,108 @@ +db_debug) + { + return $this->db->display_error('db_unsuported_feature'); + } + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Optimize table query + * + * Is optimization even supported in Interbase/Firebird? + * + * @access private + * @param string the table name + * @return object + */ + function _optimize_table($table) + { + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Repair table query + * + * Table repairs are not supported in Interbase/Firebird + * + * @access private + * @param string the table name + * @return object + */ + function _repair_table($table) + { + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Interbase/Firebird Export + * + * @access private + * @param array Preferences + * @return mixed + */ + function _backup($params = array()) + { + // Currently unsupported + return $this->db->display_error('db_unsuported_feature'); + } +} + +/* End of file interbase_utility.php */ +/* Location: ./system/database/drivers/interbase/interbase_utility.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4be822bcca94273967abf010ef67f64ead5e6bf2 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 12:07:34 -0500 Subject: Added public declarations --- .../drivers/interbase/interbase_driver.php | 62 +++++++++++----------- .../database/drivers/interbase/interbase_forge.php | 12 ++--- .../drivers/interbase/interbase_result.php | 16 +++--- .../drivers/interbase/interbase_utility.php | 8 +-- 4 files changed, 49 insertions(+), 49 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index bc9cb8f08..671b128ea 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -70,7 +70,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_connect() + public function db_connect() { if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->charset)) { @@ -95,7 +95,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->charset)) { @@ -123,7 +123,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in Interbase/Firebird } @@ -136,7 +136,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { // Connection selects the database return TRUE; @@ -152,7 +152,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string * @return resource */ - function db_set_charset($charset, $collation) + public function db_set_charset($charset, $collation) { // @todo - add support if needed return TRUE; @@ -166,7 +166,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return string */ - function _version() + public function _version() { //@todo - add support if needed return TRUE; @@ -181,7 +181,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return resource */ - function _execute($sql) + public function _execute($sql) { $sql = $this->_prep_query($sql); return @ibase_query($this->conn_id, $sql); @@ -198,7 +198,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return string */ - function _prep_query($sql) + public function _prep_query($sql) { return $sql; } @@ -211,7 +211,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return bool */ - function trans_begin($test_mode = FALSE) + public function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -242,7 +242,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -268,7 +268,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -296,7 +296,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + public function escape_str($str, $like = FALSE) { if (is_array($str)) { @@ -327,7 +327,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return integer */ - function affected_rows() + public function affected_rows() { return @ibase_affected_rows($this->conn_id); } @@ -340,7 +340,7 @@ class CI_DB_interbase_driver extends CI_DB { * @access public * @return integer */ - function insert_id() + public function insert_id() { //@todo Implement manually return 0; @@ -358,7 +358,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -388,7 +388,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param boolean * @return string */ - function _list_tables($prefix_limit = FALSE) + public function _list_tables($prefix_limit = FALSE) { $sql = <<_reserved_identifiers as $id) { @@ -504,14 +504,14 @@ SQL; /** * From Tables * - * This function implicitly groups FROM tables so there is no confusion + * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * * @access public * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -534,7 +534,7 @@ SQL; * @param array the insert values * @return string */ - function _insert($table, $keys, $values) + public function _insert($table, $keys, $values) { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } @@ -554,7 +554,7 @@ SQL; * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -582,13 +582,13 @@ SQL; * * Generates a platform-specific truncate string from the supplied data * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" + * This public function maps to "DELETE FROM table" * * @access public * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return $this->_delete($table); } @@ -606,7 +606,7 @@ SQL; * @param string the limit clause * @return string */ - function _delete($table, $where = array(), $like = array(), $limit = FALSE) + public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -640,7 +640,7 @@ SQL; * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { if ($offset == 0) { @@ -663,7 +663,7 @@ SQL; * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { @ibase_close($conn_id); } diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 36d980b67..815107d85 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -43,7 +43,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the database name * @return bool */ - function _create_database() + public function _create_database() { // In Interbase/Firebird, a database is created when you connect to the database. // We'll return TRUE so that an error isn't generated @@ -60,7 +60,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * - the current db is dropped * @return bool */ - function _drop_database($name='') + public function _drop_database($name='') { return ibase_drop_db($this->conn_id); } @@ -77,7 +77,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -174,7 +174,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @access private * @return bool */ - function _drop_table($table) + public function _drop_table($table) { if ($this->db->db_debug) { @@ -201,7 +201,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return object */ - function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); @@ -251,7 +251,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); return $sql; diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index d811fc608..9d827895d 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -44,7 +44,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return integer */ - function num_rows() + public function num_rows() { //Will have to manually calculate :( $count = 0; @@ -65,7 +65,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return integer */ - function num_fields() + public function num_fields() { return @ibase_num_fields($this->result_id); } @@ -80,7 +80,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return array */ - function list_fields() + public function list_fields() { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) @@ -102,7 +102,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access public * @return array */ - function field_data() + public function field_data() { $retval = array(); @@ -130,7 +130,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return null */ - function free_result() + public function free_result() { @ibase_free_result($this->result_id); } @@ -147,7 +147,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access private * @return array */ - function _data_seek($n = 0) + public function _data_seek($n = 0) { //Interbase driver doesn't implement a sutable function return array(); @@ -163,7 +163,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access private * @return array */ - function _fetch_assoc() + public function _fetch_assoc() { return @ibase_fetch_assoc($this->result_id); } @@ -178,7 +178,7 @@ class CI_DB_interbase_result extends CI_DB_result { * @access private * @return object */ - function _fetch_object() + public function _fetch_object() { return @ibase_fetch_object($this->result_id); } diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index 533a269b2..d90ecae71 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -47,7 +47,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @access private * @return bool */ - function _list_databases() + public function _list_databases() { if ($this->db_debug) { @@ -67,7 +67,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @param string the table name * @return object */ - function _optimize_table($table) + public function _optimize_table($table) { return FALSE; } @@ -83,7 +83,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @param string the table name * @return object */ - function _repair_table($table) + public function _repair_table($table) { return FALSE; } @@ -97,7 +97,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { * @param array Preferences * @return mixed */ - function _backup($params = array()) + public function _backup($params = array()) { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); -- cgit v1.2.3-24-g4f1b From 2d6ae793daf6eafe72c33f2bc39e18a22f699264 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 15:00:52 -0500 Subject: Various fixes --- .../drivers/interbase/interbase_driver.php | 226 +++++++++++---------- 1 file changed, 115 insertions(+), 111 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 671b128ea..ff9f2d5bf 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -14,15 +14,15 @@ * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it * through the world wide web, please send an email to - * licensing@ellislab.com so we can send you a copy immediately. + * licensingellislab.com so we can send you a copy immediately. * - * @package CodeIgniter - * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) - * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * @link http://codeigniter.com - * @since Version 3.0 - * @filesource + * package CodeIgniter + * author EllisLab Dev Team + * copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) + * license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * link http://codeigniter.com + * since Version 3.0 + * filesource */ // ------------------------------------------------------------------------ @@ -36,11 +36,11 @@ * creates dynamically based on whether the active record * class is being used or not. * - * @package CodeIgniter - * @subpackage Drivers - * @category Database - * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/database/ + * package CodeIgniter + * subpackage Drivers + * category Database + * author EllisLab Dev Team + * link http://codeigniter.com/user_guide/database/ */ class CI_DB_interbase_driver extends CI_DB { @@ -67,12 +67,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Non-persistent database connection * - * @access private called by the base class - * @return resource + * access private called by the base class + * return resource */ public function db_connect() { - if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->charset)) + if ( ! $conn_id = ibase_connect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -92,12 +92,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class - * @return resource + * access private called by the base class + * return resource */ public function db_pconnect() { - if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->charset)) + if ( ! $conn_id = ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -120,8 +120,8 @@ class CI_DB_interbase_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public - * @return void + * access public + * return void */ public function reconnect() { @@ -133,8 +133,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * @access private called by the base class - * @return resource + * access private called by the base class + * return resource */ public function db_select() { @@ -147,14 +147,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Set client character set * - * @access public - * @param string - * @param string - * @return resource + * access public + * param string + * param string + * return resource */ public function db_set_charset($charset, $collation) { - // @todo - add support if needed + // todo - add support if needed return TRUE; } @@ -163,12 +163,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Version number query string * - * @access public - * @return string + * access public + * return string */ public function _version() { - //@todo - add support if needed + //todo - add support if needed return TRUE; } @@ -177,14 +177,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class - * @param string an SQL query - * @return resource + * access private called by the base class + * param string an SQL query + * return resource */ public function _execute($sql) { $sql = $this->_prep_query($sql); - return @ibase_query($this->conn_id, $sql); + return ibase_query($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -194,9 +194,9 @@ class CI_DB_interbase_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() - * @param string an SQL query - * @return string + * access private called by execute() + * param string an SQL query + * return string */ public function _prep_query($sql) { @@ -208,8 +208,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Begin Transaction * - * @access public - * @return bool + * access public + * return bool */ public function trans_begin($test_mode = FALSE) { @@ -229,7 +229,7 @@ class CI_DB_interbase_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; - $this->trans = @ibase_trans($this->conn_id); + $this->trans = ibase_trans($this->conn_id); return TRUE; } @@ -239,8 +239,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Commit Transaction * - * @access public - * @return bool + * access public + * return bool */ public function trans_commit() { @@ -255,7 +255,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_commit($this->trans); + ibase_commit($this->trans); return TRUE; } @@ -265,8 +265,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Rollback Transaction * - * @access public - * @return bool + * access public + * return bool */ public function trans_rollback() { @@ -281,7 +281,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_rollback($this->trans); + ibase_rollback($this->trans); return TRUE; } @@ -291,10 +291,10 @@ class CI_DB_interbase_driver extends CI_DB { /** * Escape String * - * @access public - * @param string - * @param bool whether or not the string will be used in a LIKE condition - * @return string + * access public + * param string + * param bool whether or not the string will be used in a LIKE condition + * return string */ public function escape_str($str, $like = FALSE) { @@ -324,12 +324,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * access public + * return integer */ public function affected_rows() { - return @ibase_affected_rows($this->conn_id); + return ibase_affected_rows($this->conn_id); } // -------------------------------------------------------------------- @@ -337,12 +337,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * access public + * return integer */ public function insert_id() { - //@todo Implement manually + //todo Implement manually return 0; } @@ -354,9 +354,9 @@ class CI_DB_interbase_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public - * @param string - * @return string + * access public + * param string + * return string */ public function count_all($table = '') { @@ -384,9 +384,9 @@ class CI_DB_interbase_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private - * @param boolean - * @return string + * access private + * param boolean + * return string */ public function _list_tables($prefix_limit = FALSE) { @@ -410,9 +410,9 @@ SQL; * * Generates a platform-specific query string so that the column names can be fetched * - * @access public - * @param string the table name - * @return string + * access public + * param string the table name + * return string */ public function _list_columns($table = '') { @@ -427,9 +427,9 @@ SQL; * * Generates a platform-specific query so that the column data can be retrieved * - * @access public - * @param string the table name - * @return object + * access public + * param string the table name + * return object */ public function _field_data($table) { @@ -441,8 +441,8 @@ SQL; /** * The error message string * - * @access private - * @return string + * access private + * return string */ public function _error_message() { @@ -454,8 +454,8 @@ SQL; /** * The error message number * - * @access private - * @return integer + * access private + * return integer */ public function _error_number() { @@ -469,9 +469,9 @@ SQL; * * This public function escapes column and table names * - * @access private - * @param string - * @return string + * access private + * param string + * return string */ public function _escape_identifiers($item) { @@ -496,7 +496,7 @@ SQL; } // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); + return strtoupper(preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str)); } // -------------------------------------------------------------------- @@ -507,9 +507,9 @@ SQL; * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public - * @param type - * @return type + * access public + * param type + * return type */ public function _from_tables($tables) { @@ -518,7 +518,7 @@ SQL; $tables = array($tables); } - return '('.implode(', ', $tables).')'; + return strtolower(implode(', ', $tables)); } // -------------------------------------------------------------------- @@ -528,15 +528,15 @@ SQL; * * Generates a platform-specific insert string from the supplied data * - * @access public - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * access public + * param string the table name + * param array the insert keys + * param array the insert values + * return string */ public function _insert($table, $keys, $values) { - return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return "INSERT INTO ".strtolower($table)." (".strtoupper(implode(', ', $keys)).") VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -546,16 +546,18 @@ SQL; * * Generates a platform-specific update string from the supplied data * - * @access public - * @param string the table name - * @param array the update data - * @param array the where clause - * @param array the orderby clause - * @param array the limit clause - * @return string + * access public + * param string the table name + * param array the update data + * param array the where clause + * param array the orderby clause + * param array the limit clause + * return string */ public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { + $table = strtolower($table); + foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; @@ -584,9 +586,9 @@ SQL; * If the database does not support the truncate() command * This public function maps to "DELETE FROM table" * - * @access public - * @param string the table name - * @return string + * access public + * param string the table name + * return string */ public function _truncate($table) { @@ -600,14 +602,16 @@ SQL; * * Generates a platform-specific delete string from the supplied data * - * @access public - * @param string the table name - * @param array the where clause - * @param string the limit clause - * @return string + * access public + * param string the table name + * param array the where clause + * param string the limit clause + * return string */ public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { + $table = strtolower($table); + $conditions = ''; if (count($where) > 0 OR count($like) > 0) @@ -634,11 +638,11 @@ SQL; * * Generates a platform-specific LIMIT clause * - * @access public - * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value - * @return string + * access public + * param string the sql query string + * param integer the number of rows to limit the query to + * param integer the offset value + * return string */ public function _limit($sql, $limit, $offset) { @@ -659,13 +663,13 @@ SQL; /** * Close DB Connection * - * @access public - * @param resource - * @return void + * access public + * param resource + * return void */ public function _close($conn_id) { - @ibase_close($conn_id); + ibase_close($conn_id); } -- cgit v1.2.3-24-g4f1b From 7221f9455b3ffe89474d1728583b656c176b5ba4 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 15:02:33 -0500 Subject: Restored '@' characters --- .../drivers/interbase/interbase_driver.php | 218 ++++++++++----------- 1 file changed, 108 insertions(+), 110 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index ff9f2d5bf..525294db4 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -14,15 +14,15 @@ * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it * through the world wide web, please send an email to - * licensingellislab.com so we can send you a copy immediately. + * licensing@ellislab.com so we can send you a copy immediately. * - * package CodeIgniter - * author EllisLab Dev Team - * copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) - * license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * link http://codeigniter.com - * since Version 3.0 - * filesource + * @package CodeIgniter + * @author EllisLab Dev Team + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * @link http://codeigniter.com + * @since Version 3.0 + * @filesource */ // ------------------------------------------------------------------------ @@ -36,11 +36,11 @@ * creates dynamically based on whether the active record * class is being used or not. * - * package CodeIgniter - * subpackage Drivers - * category Database - * author EllisLab Dev Team - * link http://codeigniter.com/user_guide/database/ + * @package CodeIgniter + * @subpackage Drivers + * @category Database + * @author EllisLab Dev Team + * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_interbase_driver extends CI_DB { @@ -67,12 +67,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Non-persistent database connection * - * access private called by the base class - * return resource + * @access private called by the base class + * @return resource */ public function db_connect() { - if ( ! $conn_id = ibase_connect($this->database, $this->username, $this->password, $this->char_set)) + if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -92,12 +92,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Persistent database connection * - * access private called by the base class - * return resource + * @access private called by the base class + * @return resource */ public function db_pconnect() { - if ( ! $conn_id = ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) + if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) { log_message('error', $error); @@ -120,8 +120,8 @@ class CI_DB_interbase_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * access public - * return void + * @access public + * @return void */ public function reconnect() { @@ -133,8 +133,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * access private called by the base class - * return resource + * @access private called by the base class + * @return resource */ public function db_select() { @@ -147,14 +147,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Set client character set * - * access public - * param string - * param string - * return resource + * @access public + * @param string + * @param string + * @return resource */ public function db_set_charset($charset, $collation) { - // todo - add support if needed + // @todo - add support if needed return TRUE; } @@ -163,12 +163,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Version number query string * - * access public - * return string + * @access public + * @return string */ public function _version() { - //todo - add support if needed + //@todo - add support if needed return TRUE; } @@ -177,14 +177,14 @@ class CI_DB_interbase_driver extends CI_DB { /** * Execute the query * - * access private called by the base class - * param string an SQL query - * return resource + * @access private called by the base class + * @param string an SQL query + * @return resource */ public function _execute($sql) { $sql = $this->_prep_query($sql); - return ibase_query($this->conn_id, $sql); + return @ibase_query($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -194,9 +194,9 @@ class CI_DB_interbase_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * access private called by execute() - * param string an SQL query - * return string + * @access private called by execute() + * @param string an SQL query + * @return string */ public function _prep_query($sql) { @@ -208,8 +208,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Begin Transaction * - * access public - * return bool + * @access public + * @return bool */ public function trans_begin($test_mode = FALSE) { @@ -229,7 +229,7 @@ class CI_DB_interbase_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; - $this->trans = ibase_trans($this->conn_id); + $this->trans = @ibase_trans($this->conn_id); return TRUE; } @@ -239,8 +239,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Commit Transaction * - * access public - * return bool + * @access public + * @return bool */ public function trans_commit() { @@ -255,7 +255,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - ibase_commit($this->trans); + @ibase_commit($this->trans); return TRUE; } @@ -265,8 +265,8 @@ class CI_DB_interbase_driver extends CI_DB { /** * Rollback Transaction * - * access public - * return bool + * @access public + * @return bool */ public function trans_rollback() { @@ -281,7 +281,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - ibase_rollback($this->trans); + @ibase_rollback($this->trans); return TRUE; } @@ -291,10 +291,10 @@ class CI_DB_interbase_driver extends CI_DB { /** * Escape String * - * access public - * param string - * param bool whether or not the string will be used in a LIKE condition - * return string + * @access public + * @param string + * @param bool whether or not the string will be used in a LIKE condition + * @return string */ public function escape_str($str, $like = FALSE) { @@ -324,12 +324,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Affected Rows * - * access public - * return integer + * @access public + * @return integer */ public function affected_rows() { - return ibase_affected_rows($this->conn_id); + return @ibase_affected_rows($this->conn_id); } // -------------------------------------------------------------------- @@ -337,12 +337,12 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * access public - * return integer + * @access public + * @return integer */ public function insert_id() { - //todo Implement manually + //@todo Implement manually return 0; } @@ -354,9 +354,9 @@ class CI_DB_interbase_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * access public - * param string - * return string + * @access public + * @param string + * @return string */ public function count_all($table = '') { @@ -384,9 +384,9 @@ class CI_DB_interbase_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * access private - * param boolean - * return string + * @access private + * @param boolean + * @return string */ public function _list_tables($prefix_limit = FALSE) { @@ -410,9 +410,9 @@ SQL; * * Generates a platform-specific query string so that the column names can be fetched * - * access public - * param string the table name - * return string + * @access public + * @param string the table name + * @return string */ public function _list_columns($table = '') { @@ -427,9 +427,9 @@ SQL; * * Generates a platform-specific query so that the column data can be retrieved * - * access public - * param string the table name - * return object + * @access public + * @param string the table name + * @return object */ public function _field_data($table) { @@ -441,8 +441,8 @@ SQL; /** * The error message string * - * access private - * return string + * @access private + * @return string */ public function _error_message() { @@ -454,8 +454,8 @@ SQL; /** * The error message number * - * access private - * return integer + * @access private + * @return integer */ public function _error_number() { @@ -469,9 +469,9 @@ SQL; * * This public function escapes column and table names * - * access private - * param string - * return string + * @access private + * @param string + * @return string */ public function _escape_identifiers($item) { @@ -507,9 +507,9 @@ SQL; * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * access public - * param type - * return type + * @access public + * @param type + * @return type */ public function _from_tables($tables) { @@ -528,11 +528,11 @@ SQL; * * Generates a platform-specific insert string from the supplied data * - * access public - * param string the table name - * param array the insert keys - * param array the insert values - * return string + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ public function _insert($table, $keys, $values) { @@ -546,13 +546,13 @@ SQL; * * Generates a platform-specific update string from the supplied data * - * access public - * param string the table name - * param array the update data - * param array the where clause - * param array the orderby clause - * param array the limit clause - * return string + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @param array the orderby clause + * @param array the limit clause + * @return string */ public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { @@ -586,9 +586,9 @@ SQL; * If the database does not support the truncate() command * This public function maps to "DELETE FROM table" * - * access public - * param string the table name - * return string + * @access public + * @param string the table name + * @return string */ public function _truncate($table) { @@ -602,11 +602,11 @@ SQL; * * Generates a platform-specific delete string from the supplied data * - * access public - * param string the table name - * param array the where clause - * param string the limit clause - * return string + * @access public + * @param string the table name + * @param array the where clause + * @param string the limit clause + * @return string */ public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { @@ -638,11 +638,11 @@ SQL; * * Generates a platform-specific LIMIT clause * - * access public - * param string the sql query string - * param integer the number of rows to limit the query to - * param integer the offset value - * return string + * @access public + * @param string the sql query string + * @param integer the number of rows to limit the query to + * @param integer the offset value + * @return string */ public function _limit($sql, $limit, $offset) { @@ -663,16 +663,14 @@ SQL; /** * Close DB Connection * - * access public - * param resource - * return void + * @access public + * @param resource + * @return void */ public function _close($conn_id) { - ibase_close($conn_id); + @ibase_close($conn_id); } - - } -- cgit v1.2.3-24-g4f1b From d19e47a3152c0a3e6a9aa13261b4c843c946523b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Feb 2012 23:40:40 -0500 Subject: Removed string case manipulation functions --- system/database/drivers/interbase/interbase_driver.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 525294db4..6f889d91e 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -74,11 +74,11 @@ class CI_DB_interbase_driver extends CI_DB { { if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->char_set)) { - log_message('error', $error); + log_message('error', $this->_error_message()); if ($this->db_debug) { - $this->display_error($error, '', TRUE); + $this->display_error($this->_error_message(), '', TRUE); } return FALSE; @@ -99,11 +99,11 @@ class CI_DB_interbase_driver extends CI_DB { { if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) { - log_message('error', $error); + log_message('error', $this->_error_message()); if ($this->db_debug) { - $this->display_error($error, '', TRUE); + $this->display_error($this->_error_message(), '', TRUE); } return FALSE; @@ -496,7 +496,7 @@ SQL; } // remove duplicates if the user already included the escape - return strtoupper(preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str)); + return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } // -------------------------------------------------------------------- @@ -518,7 +518,7 @@ SQL; $tables = array($tables); } - return strtolower(implode(', ', $tables)); + return implode(', ', $tables); } // -------------------------------------------------------------------- @@ -536,7 +536,7 @@ SQL; */ public function _insert($table, $keys, $values) { - return "INSERT INTO ".strtolower($table)." (".strtoupper(implode(', ', $keys)).") VALUES (".implode(', ', $values).")"; + return "INSERT INTO {$table} (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } // -------------------------------------------------------------------- @@ -556,8 +556,6 @@ SQL; */ public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { - $table = strtolower($table); - foreach ($values as $key => $val) { $valstr[] = $key." = ".$val; @@ -610,8 +608,6 @@ SQL; */ public function _delete($table, $where = array(), $like = array(), $limit = FALSE) { - $table = strtolower($table); - $conditions = ''; if (count($where) > 0 OR count($like) > 0) -- cgit v1.2.3-24-g4f1b From 498fa354888c1fc4083d1e464b651498d9338b64 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 15 Feb 2012 10:05:49 -0500 Subject: Minor codestyle fix --- system/database/drivers/interbase/interbase_driver.php | 2 -- system/database/drivers/interbase/interbase_utility.php | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 6f889d91e..a011f103d 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -27,8 +27,6 @@ // ------------------------------------------------------------------------ - - /** * Firebird/Interbase Database Adapter Class * diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index d90ecae71..764275567 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -100,6 +100,7 @@ class CI_DB_interbase_utility extends CI_DB_utility { public function _backup($params = array()) { // Currently unsupported + // @todo See if can be implemented return $this->db->display_error('db_unsuported_feature'); } } -- cgit v1.2.3-24-g4f1b From 3d985a19ac05a8f5141b51fed9b1b37946733792 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 15 Feb 2012 11:38:00 -0500 Subject: Syntax fixes --- .../drivers/interbase/interbase_driver.php | 27 ++++++++++------------ .../database/drivers/interbase/interbase_forge.php | 13 ++--------- 2 files changed, 14 insertions(+), 26 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index a011f103d..36ef42ef3 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -152,7 +152,7 @@ class CI_DB_interbase_driver extends CI_DB { */ public function db_set_charset($charset, $collation) { - // @todo - add support if needed + // Must be determined at connection return TRUE; } @@ -166,8 +166,13 @@ class CI_DB_interbase_driver extends CI_DB { */ public function _version() { - //@todo - add support if needed - return TRUE; + if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) + { + $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); + return $version; + } + + return FALSE; } // -------------------------------------------------------------------- @@ -396,7 +401,7 @@ SQL; if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); + $sql .= ' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } return $sql; } @@ -620,7 +625,7 @@ SQL; $conditions .= implode("\n", $like); } - $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; + //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit; return "DELETE FROM ".$table.$conditions.$limit; } @@ -640,16 +645,8 @@ SQL; */ public function _limit($sql, $limit, $offset) { - if ($offset == 0) - { - $offset = ''; - } - else - { - $offset .= ", "; - } - - return $sql."LIMIT ".$offset.$limit; + //There doesn't seem to be a limit clause? + return $sql; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 815107d85..177433fc4 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -205,20 +205,11 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); - // DROP has everything it needs now. - /*if ($alter_type == 'DROP') - { - // SQLite does not support dropping columns - // http://www.sqlite.org/omitted.html - // http://www.sqlite.org/faq.html#q11 - return FALSE; - }*/ - - $sql .= " $column_definition"; + $sql .= " {$column_definition}"; if ($default_value != '') { - $sql .= " DEFAULT \"$default_value\""; + $sql .= " DEFAULT \"{$default_value}\""; } if ($null === NULL) -- cgit v1.2.3-24-g4f1b From 8be31a92758959d7fd7b035e36b9799da13426ae Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 15 Feb 2012 11:48:57 -0500 Subject: Limit clause fixes --- system/database/drivers/interbase/interbase_driver.php | 12 +++++++----- system/database/drivers/interbase/interbase_result.php | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'system/database/drivers/interbase') 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(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 197c01401..8a156af53 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -419,8 +419,17 @@ SQL; */ public function _list_columns($table = '') { - // Not supported - return FALSE; + $sql = << Date: Wed, 15 Feb 2012 18:40:39 -0500 Subject: Implemented insert_id() method --- system/database/drivers/interbase/interbase_driver.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 8a156af53..97bf722db 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -341,12 +341,13 @@ class CI_DB_interbase_driver extends CI_DB { * Insert ID * * @access public + * @param string $generator_name + * @param integer $inc_by * @return integer */ - public function insert_id() + public function insert_id($generator_name, $inc_by=1) { - //@todo Implement manually - return 0; + return ibase_gen_id($generator_name, $inc_by); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 817af19bb12b88bae361034e00ce3a02da595f94 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 16 Feb 2012 08:28:00 -0500 Subject: narfbg suggested fixes --- .../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 +-- 4 files changed, 43 insertions(+), 105 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 97bf722db..a6f192ad1 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -1,13 +1,13 @@ -hostname) && $this->hostname !== "localhost") + { + $this->database = $this->hostname.':'.$this->database; + } + } /** * Non-persistent database connection * - * @access private called by the base class * @return resource */ public function db_connect() { - if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->char_set)) - { - log_message('error', $this->_error_message()); - - if ($this->db_debug) - { - $this->display_error($this->_error_message(), '', TRUE); - } - - return FALSE; - } - - return $conn_id; + return @ibase_connect($this->database, $this->username, $this->password, $this->char_set); } // -------------------------------------------------------------------- @@ -90,24 +88,11 @@ class CI_DB_interbase_driver extends CI_DB { /** * Persistent database connection * - * @access private called by the base class * @return resource */ public function db_pconnect() { - if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set)) - { - log_message('error', $this->_error_message()); - - if ($this->db_debug) - { - $this->display_error($this->_error_message(), '', TRUE); - } - - return FALSE; - } - - return $conn_id; + return @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set); } // -------------------------------------------------------------------- @@ -118,7 +103,6 @@ class CI_DB_interbase_driver extends CI_DB { * Keep / reestablish the db connection if no queries have been * sent for a length of time exceeding the server's idle timeout * - * @access public * @return void */ public function reconnect() @@ -131,7 +115,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * @access private called by the base class * @return resource */ public function db_select() @@ -145,7 +128,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Set client character set * - * @access public * @param string * @param string * @return resource @@ -161,7 +143,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Version number query string * - * @access public * @return string */ public function _version() @@ -180,7 +161,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class * @param string an SQL query * @return resource */ @@ -197,7 +177,6 @@ class CI_DB_interbase_driver extends CI_DB { * * If needed, each database adapter can prep the query string * - * @access private called by execute() * @param string an SQL query * @return string */ @@ -211,7 +190,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Begin Transaction * - * @access public * @return bool */ public function trans_begin($test_mode = FALSE) @@ -242,7 +220,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Commit Transaction * - * @access public * @return bool */ public function trans_commit() @@ -268,7 +245,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Rollback Transaction * - * @access public * @return bool */ public function trans_rollback() @@ -294,7 +270,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Escape String * - * @access public * @param string * @param bool whether or not the string will be used in a LIKE condition * @return string @@ -327,7 +302,6 @@ class CI_DB_interbase_driver extends CI_DB { /** * Affected Rows * - * @access public * @return integer */ public function affected_rows() @@ -340,12 +314,11 @@ class CI_DB_interbase_driver extends CI_DB { /** * Insert ID * - * @access public * @param string $generator_name * @param integer $inc_by * @return integer */ - public function insert_id($generator_name, $inc_by=1) + public function insert_id($generator_name, $inc_by=0) { return ibase_gen_id($generator_name, $inc_by); } @@ -358,7 +331,6 @@ class CI_DB_interbase_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public * @param string * @return string */ @@ -369,7 +341,7 @@ class CI_DB_interbase_driver extends CI_DB { return 0; } - $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) { @@ -388,7 +360,6 @@ class CI_DB_interbase_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private * @param boolean * @return string */ @@ -414,7 +385,6 @@ SQL; * * Generates a platform-specific query string so that the column names can be fetched * - * @access public * @param string the table name * @return string */ @@ -440,7 +410,6 @@ SQL; * * Generates a platform-specific query so that the column data can be retrieved * - * @access public * @param string the table name * @return object */ @@ -457,7 +426,6 @@ SQL; /** * The error message string * - * @access private * @return string */ public function _error_message() @@ -470,7 +438,6 @@ SQL; /** * The error message number * - * @access private * @return integer */ public function _error_number() @@ -485,7 +452,6 @@ SQL; * * This public function escapes column and table names * - * @access private * @param string * @return string */ @@ -523,7 +489,6 @@ SQL; * This public function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public * @param type * @return type */ @@ -534,6 +499,7 @@ SQL; $tables = array($tables); } + //Interbase/Firebird doesn't like grouped tables return implode(', ', $tables); } @@ -544,7 +510,6 @@ SQL; * * Generates a platform-specific insert string from the supplied data * - * @access public * @param string the table name * @param array the insert keys * @param array the insert values @@ -552,7 +517,7 @@ SQL; */ public function _insert($table, $keys, $values) { - return "INSERT INTO {$table} (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } // -------------------------------------------------------------------- @@ -562,7 +527,6 @@ SQL; * * Generates a platform-specific update string from the supplied data * - * @access public * @param string the table name * @param array the update data * @param array the where clause @@ -581,9 +545,9 @@ SQL; $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); + $sql = "UPDATE {$table} SET ".implode(', ', $valstr); - $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; + $sql .= ($where != '' AND count($where) >=1) ? ' WHERE '.implode(' ', $where) : ''; $sql .= $orderby; @@ -600,7 +564,6 @@ SQL; * If the database does not support the truncate() command * This public function maps to "DELETE FROM table" * - * @access public * @param string the table name * @return string */ @@ -616,7 +579,6 @@ SQL; * * Generates a platform-specific delete string from the supplied data * - * @access public * @param string the table name * @param array the where clause * @param string the limit clause @@ -633,7 +595,7 @@ SQL; if (count($where) > 0 && count($like) > 0) { - $conditions .= " AND "; + $conditions .= ' AND '; } $conditions .= implode("\n", $like); } @@ -650,7 +612,6 @@ SQL; * * Generates a platform-specific LIMIT clause * - * @access public * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value @@ -667,7 +628,6 @@ SQL; /** * Close DB Connection * - * @access public * @param resource * @return void */ diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 177433fc4..6301481c5 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -1,13 +1,13 @@ -db->db_debug) - { - return $this->db->display_error('db_unsuported_feature'); - } - return array(); + return 'DROP TABLE '.$name; } // -------------------------------------------------------------------- @@ -191,7 +183,6 @@ class CI_DB_interbase_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param string the table name @@ -237,14 +228,13 @@ class CI_DB_interbase_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ public function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); + $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); return $sql; } } diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index f2465ab5d..7d56c56c6 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -1,13 +1,13 @@ -result_id)) + if( ! is_null($this->num_rows)) { - $count++; + return $this->num_rows; } - return $count; + return $this->num_rows = (isset($this->result_array()) ? count($this->result_array()) : 0; } // -------------------------------------------------------------------- @@ -62,7 +60,6 @@ class CI_DB_interbase_result extends CI_DB_result { /** * Number of fields in the result set * - * @access public * @return integer */ public function num_fields() @@ -77,13 +74,12 @@ class CI_DB_interbase_result extends CI_DB_result { * * Generates an array of column names * - * @access public * @return array */ public function list_fields() { $field_names = array(); - for ($i = 0; $i < $this->num_fields(); $i++) + for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); $field_names[] = $info['name']; @@ -99,14 +95,13 @@ class CI_DB_interbase_result extends CI_DB_result { * * Generates an array of objects containing field meta-data * - * @access public * @return array */ public function field_data() { $retval = array(); - for ($i = 0; $i < $this->num_fields(); $i++) + for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); @@ -144,13 +139,12 @@ class CI_DB_interbase_result extends CI_DB_result { * this internally before fetching results to make sure the * result set starts at zero * - * @access private * @return array */ public function _data_seek($n = 0) { //Interbase driver doesn't implement a suitable function - return array(); + return FALSE; } // -------------------------------------------------------------------- @@ -160,7 +154,6 @@ class CI_DB_interbase_result extends CI_DB_result { * * Returns the result set as an array * - * @access private * @return array */ public function _fetch_assoc() @@ -175,7 +168,6 @@ class CI_DB_interbase_result extends CI_DB_result { * * Returns the result set as an object * - * @access private * @return object */ public function _fetch_object() diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index 764275567..e31021acb 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -1,13 +1,13 @@ -db->display_error('db_unsuported_feature'); } - return array(); + return FALSE; } // -------------------------------------------------------------------- @@ -63,7 +62,6 @@ class CI_DB_interbase_utility extends CI_DB_utility { * * Is optimization even supported in Interbase/Firebird? * - * @access private * @param string the table name * @return object */ @@ -79,7 +77,6 @@ class CI_DB_interbase_utility extends CI_DB_utility { * * Table repairs are not supported in Interbase/Firebird * - * @access private * @param string the table name * @return object */ @@ -93,7 +90,6 @@ class CI_DB_interbase_utility extends CI_DB_utility { /** * Interbase/Firebird Export * - * @access private * @param array Preferences * @return mixed */ -- cgit v1.2.3-24-g4f1b From e27216f88443775534e185e192996353d4958387 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 16 Feb 2012 12:15:45 -0500 Subject: Num rows fix --- system/database/drivers/interbase/interbase_result.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 7d56c56c6..3d5721138 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -52,7 +52,7 @@ class CI_DB_interbase_result extends CI_DB_result { return $this->num_rows; } - return $this->num_rows = (isset($this->result_array()) ? count($this->result_array()) : 0; + return 0; } // -------------------------------------------------------------------- @@ -143,6 +143,9 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function _data_seek($n = 0) { + //Set the row count to 0 + $this->num_rows = 0; + //Interbase driver doesn't implement a suitable function return FALSE; } @@ -158,6 +161,9 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function _fetch_assoc() { + //Increment row count + $this->num_rows++; + return @ibase_fetch_assoc($this->result_id); } @@ -172,6 +178,9 @@ class CI_DB_interbase_result extends CI_DB_result { */ public function _fetch_object() { + //Increment row count + $this->num_rows++; + return @ibase_fetch_object($this->result_id); } -- cgit v1.2.3-24-g4f1b From 3c4281f09dce0a97ab700d79e26308fdab350b73 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 16 Feb 2012 19:00:10 -0500 Subject: Simplified hostname connection logic --- system/database/drivers/interbase/interbase_driver.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'system/database/drivers/interbase') 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(+) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 20663d8bb..7bd4f6f4b 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -624,6 +624,59 @@ SQL; { @ibase_close($conn_id); } + + // -------------------------------------------------------------------------- + + /** + * Returns an array of table names + * + * @access public + * @return array + */ + function list_tables($constrain_by_prefix = FALSE) + { + // Is there a cached result? + if (isset($this->data_cache['table_names'])) + { + return $this->data_cache['table_names']; + } + + if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) + { + if ($this->db_debug) + { + return $this->display_error('db_unsupported_function'); + } + return FALSE; + } + + $retval = array(); + $query = $this->query($sql); + + $table = FALSE; + $rows = $query->result_array(); + + // This has to be called after getting the result due to the + // limitations of the database driver + if ($query->num_rows() > 0) + { + $key = (($row = current($rows)) && in_array('table_name', array_map('strtolower', array_keys($row)))); + + if ($key) + { + $table = array_key_exists('TABLE_NAME', $row) ? 'TABLE_NAME' : 'table_name'; + } + + foreach ($rows as $row) + { + $retval[] = ( ! $table) ? current($row) : $row[$table]; + } + } + + $this->data_cache['table_names'] = $retval; + + return $this->data_cache['table_names']; + } } /* End of file interbase_driver.php */ diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 3d5721138..37f0a108c 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -183,6 +183,68 @@ class CI_DB_interbase_result extends CI_DB_result { return @ibase_fetch_object($this->result_id); } + + // -------------------------------------------------------------------- + + /** + * Query result. "object" version. + * + * @return object + */ + public function result_object() + { + if (count($this->result_object) > 0) + { + return $this->result_object; + } + + // In the event that query caching is on the result_id variable + // will return FALSE since there isn't a valid SQL resource so + // we'll simply return an empty array. + if ($this->result_id === FALSE) + { + return array(); + } + + $this->num_rows = 0; + while ($row = $this->_fetch_object()) + { + $this->result_object[] = $row; + } + + return $this->result_object; + } + + // -------------------------------------------------------------------- + + /** + * Query result. "array" version. + * + * @return array + */ + public function result_array() + { + if (count($this->result_array) > 0) + { + return $this->result_array; + } + + // In the event that query caching is on the result_id variable + // will return FALSE since there isn't a valid SQL resource so + // we'll simply return an empty array. + if ($this->result_id === FALSE) + { + return array(); + } + + $this->num_rows = 0; + while ($row = $this->_fetch_assoc()) + { + $this->result_array[] = $row; + } + + return $this->result_array; + } } -- cgit v1.2.3-24-g4f1b From 7d42eb39484a784496868f4446a2d47b0c52410d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 14:21:18 -0500 Subject: More general fix for num_rows --- .../drivers/interbase/interbase_driver.php | 53 ---------------------- .../drivers/interbase/interbase_result.php | 5 +- 2 files changed, 4 insertions(+), 54 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 7bd4f6f4b..20663d8bb 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -624,59 +624,6 @@ SQL; { @ibase_close($conn_id); } - - // -------------------------------------------------------------------------- - - /** - * Returns an array of table names - * - * @access public - * @return array - */ - function list_tables($constrain_by_prefix = FALSE) - { - // Is there a cached result? - if (isset($this->data_cache['table_names'])) - { - return $this->data_cache['table_names']; - } - - if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) - { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; - } - - $retval = array(); - $query = $this->query($sql); - - $table = FALSE; - $rows = $query->result_array(); - - // This has to be called after getting the result due to the - // limitations of the database driver - if ($query->num_rows() > 0) - { - $key = (($row = current($rows)) && in_array('table_name', array_map('strtolower', array_keys($row)))); - - if ($key) - { - $table = array_key_exists('TABLE_NAME', $row) ? 'TABLE_NAME' : 'table_name'; - } - - foreach ($rows as $row) - { - $retval[] = ( ! $table) ? current($row) : $row[$table]; - } - } - - $this->data_cache['table_names'] = $retval; - - return $this->data_cache['table_names']; - } } /* End of file interbase_driver.php */ diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 37f0a108c..9093029dd 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -52,7 +52,10 @@ class CI_DB_interbase_result extends CI_DB_result { return $this->num_rows; } - return 0; + //Get the results so that you can get an accurate rowcount + $this->result_array(); + + return $this->num_rows; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From c2b712eb5230fc247ef81b4b88de789b9dd08cb4 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 15:58:08 -0500 Subject: implemented create_database, misc cleanup --- .../database/drivers/interbase/interbase_driver.php | 17 ++++++----------- .../database/drivers/interbase/interbase_forge.php | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 21 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 20663d8bb..bc7365e4d 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -104,7 +104,7 @@ class CI_DB_interbase_driver extends CI_DB { /** * Select the database * - * @return resource + * @return bool */ public function db_select() { @@ -119,7 +119,7 @@ class CI_DB_interbase_driver extends CI_DB { * * @param string * @param string - * @return resource + * @return bool */ public function db_set_charset($charset, $collation) { @@ -332,6 +332,8 @@ class CI_DB_interbase_driver extends CI_DB { $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); + $query->result_array(); + if ($query->num_rows() == 0) { return 0; @@ -379,17 +381,10 @@ SQL; */ public function _list_columns($table = '') { - $sql = <<hostname.':'.$filename.'"'; + } // -------------------------------------------------------------------- @@ -72,7 +73,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param mixed primary key(s) * @param mixed key(s) * @param boolean should 'IF NOT EXISTS' be added to the SQL - * @return bool + * @return string */ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { @@ -168,7 +169,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { /** * Drop Table * - * @return bool + * @return string */ public function _drop_table($table) { @@ -190,7 +191,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the default value * @param boolean should 'NOT NULL' be added * @param string the field after which we should add the new field - * @return object + * @return string */ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { @@ -234,8 +235,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { */ public function _rename_table($table_name, $new_table_name) { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); } } -- cgit v1.2.3-24-g4f1b From 0dcfd778350ce397b034f44e34397ea255b35809 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Feb 2012 17:42:34 -0500 Subject: Automatic retreival of blob fields --- system/database/drivers/interbase/interbase_result.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/drivers/interbase') 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(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index bc7365e4d..fcefa6d97 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -309,7 +309,7 @@ class CI_DB_interbase_driver extends CI_DB { */ public function insert_id($generator_name, $inc_by=0) { - return ibase_gen_id($generator_name, $inc_by); + return ibase_gen_id('"'.$generator_name.'"', $inc_by); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fa84d6186b7f61353d04132871a5223f80fa12ee Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 12:51:45 -0500 Subject: Fixed result array fetching --- system/database/drivers/interbase/interbase_result.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index c5608d977..c7b40d2ea 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -53,7 +53,7 @@ class CI_DB_interbase_result extends CI_DB_result { } //Get the results so that you can get an accurate rowcount - $this->result_array(); + $this->result(); return $this->num_rows; } @@ -231,6 +231,14 @@ class CI_DB_interbase_result extends CI_DB_result { { return $this->result_array; } + + // Since the object and array are really similar, just case + // the result object to an array if need be + if(count($this->result_object) > 0) + { + $this->result_array = (array)$this->result_object; + return $this->result_array; + } // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so -- cgit v1.2.3-24-g4f1b From 53d109dbd831506c4b9ca77f10bc1b2dba9c28d5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 13:04:48 -0500 Subject: Fix previous commit --- system/database/drivers/interbase/interbase_result.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index c7b40d2ea..de4a10b62 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -236,7 +236,11 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if(count($this->result_object) > 0) { - $this->result_array = (array)$this->result_object; + foreach($this->result_object as $obj) + { + $this->result_array[] = (array)$obj; + } + return $this->result_array; } -- cgit v1.2.3-24-g4f1b From 07b660b56dcf608b64fc1811c602c4072c276e70 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 13:23:06 -0500 Subject: Fixed insert_id possibly returning 0 --- system/database/drivers/interbase/interbase_driver.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index fcefa6d97..4044c4529 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -309,7 +309,12 @@ class CI_DB_interbase_driver extends CI_DB { */ public function insert_id($generator_name, $inc_by=0) { - return ibase_gen_id('"'.$generator_name.'"', $inc_by); + //If a generator hasn't been used before it will return 0 + if($id = ibase_gen_id('"'.$generator_name.'"', $inc_by) !== 0) + { + return $id; + } + return ibase_gen_id('"'.$generator_name.'"', 1); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 934e853d9a3a491911b72f40cb371edfaddb9c94 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 15:42:14 -0500 Subject: Revert "Fix previous commit" This reverts commit 53d109dbd831506c4b9ca77f10bc1b2dba9c28d5. --- system/database/drivers/interbase/interbase_result.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index de4a10b62..c7b40d2ea 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -236,11 +236,7 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if(count($this->result_object) > 0) { - foreach($this->result_object as $obj) - { - $this->result_array[] = (array)$obj; - } - + $this->result_array = (array)$this->result_object; return $this->result_array; } -- cgit v1.2.3-24-g4f1b From fed2d1ddecae1886486915718cb9878b7d5aea45 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 15:42:45 -0500 Subject: Revert previous commit --- system/database/drivers/interbase/interbase_driver.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 4044c4529..aeea00d7f 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -310,11 +310,7 @@ class CI_DB_interbase_driver extends CI_DB { public function insert_id($generator_name, $inc_by=0) { //If a generator hasn't been used before it will return 0 - if($id = ibase_gen_id('"'.$generator_name.'"', $inc_by) !== 0) - { - return $id; - } - return ibase_gen_id('"'.$generator_name.'"', 1); + return ibase_gen_id('"'.$generator_name.'"', $inc_by); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 51ed4ed7f6097a34ce1db7b225272bfc1b0f0bcf Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 16:01:42 -0500 Subject: Convert result_array to result_object instead of re-fetching --- .../drivers/interbase/interbase_result.php | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index c7b40d2ea..e1332ba93 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -200,6 +200,27 @@ class CI_DB_interbase_result extends CI_DB_result { { return $this->result_object; } + + // Convert result array to object so that + // We don't have to get the result again + if(count($this->result_array) > 0) + { + $i = 0; + + foreach($this->result_array as $array) + { + $this->result_object[$i] = new StdClass(); + + foreach($array as $key => $val) + { + $this->result_object[$i]->{$key} = $val; + } + + ++$i; + } + + return $this->result_object; + } // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so @@ -236,7 +257,11 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if(count($this->result_object) > 0) { - $this->result_array = (array)$this->result_object; + foreach($this->result_object as $obj) + { + $this->result_array[] = (array)$obj; + } + return $this->result_array; } -- cgit v1.2.3-24-g4f1b From 95562144da88784588fb2477fa0070576bd386a0 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 17:37:21 -0500 Subject: Set protected visibility on applicable functions/properties --- .../drivers/interbase/interbase_driver.php | 44 +++++++++++----------- .../database/drivers/interbase/interbase_forge.php | 12 +++--- .../drivers/interbase/interbase_result.php | 6 +-- 3 files changed, 30 insertions(+), 32 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index aeea00d7f..ba4f9d8d9 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -45,19 +45,19 @@ class CI_DB_interbase_driver extends CI_DB { public $dbdriver = 'interbase'; // The character used to escape with - public $_escape_char = '"'; + protected $_escape_char = '"'; // clause and character used for LIKE escape sequences - public $_like_escape_str = " ESCAPE '%s' "; - public $_like_escape_chr = '!'; + protected $_like_escape_str = " ESCAPE '%s' "; + protected $_like_escape_chr = '!'; /** * The syntax to count rows is slightly different across different * database engines, so this string appears in each driver and is * used for the count_all() and count_all_results() functions. */ - public $_count_string = "SELECT COUNT(*) AS "; - public $_random_keyword = ' Random()'; // database specific random keyword + protected $_count_string = "SELECT COUNT(*) AS "; + protected $_random_keyword = ' Random()'; // database specific random keyword // Keeps track of the resource for the current transaction protected $trans; @@ -134,7 +134,7 @@ class CI_DB_interbase_driver extends CI_DB { * * @return string */ - public function _version() + protected function _version() { if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) { @@ -153,7 +153,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return resource */ - public function _execute($sql) + protected function _execute($sql) { $sql = $this->_prep_query($sql); return @ibase_query($this->conn_id, $sql); @@ -169,7 +169,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param string an SQL query * @return string */ - public function _prep_query($sql) + protected function _prep_query($sql) { return $sql; } @@ -333,8 +333,6 @@ class CI_DB_interbase_driver extends CI_DB { $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - $query->result_array(); - if ($query->num_rows() == 0) { return 0; @@ -355,7 +353,7 @@ class CI_DB_interbase_driver extends CI_DB { * @param boolean * @return string */ - public function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = <<_reserved_identifiers as $id) { @@ -477,7 +475,7 @@ SQL; * @param type * @return type */ - public function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -500,7 +498,7 @@ SQL; * @param array the insert values * @return string */ - public function _insert($table, $keys, $values) + protected function _insert($table, $keys, $values) { return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; } @@ -519,7 +517,7 @@ SQL; * @param array the limit clause * @return string */ - public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -552,7 +550,7 @@ SQL; * @param string the table name * @return string */ - public function _truncate($table) + protected function _truncate($table) { return $this->_delete($table); } @@ -569,7 +567,7 @@ SQL; * @param string the limit clause * @return string */ - public function _delete($table, $where = array(), $like = array(), $limit = FALSE) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -602,7 +600,7 @@ SQL; * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { //There doesn't seem to be a limit clause? return $sql; @@ -616,7 +614,7 @@ SQL; * @param resource * @return void */ - public function _close($conn_id) + protected function _close($conn_id) { @ibase_close($conn_id); } diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index d9b55a87f..c7372a0bf 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -42,7 +42,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the database name * @return string */ - public function _create_database($filename='') + protected function _create_database($filename='') { // Firebird databases are flat files, so a path is required // Hostname is needed for remote access @@ -59,7 +59,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * - the current db is dropped * @return bool */ - public function _drop_database($name='') + protected function _drop_database($name='') { return ibase_drop_db($this->conn_id); } @@ -75,7 +75,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return string */ - public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; @@ -171,7 +171,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * * @return string */ - public function _drop_table($table) + protected function _drop_table($table) { return 'DROP TABLE '.$name; } @@ -193,7 +193,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the field after which we should add the new field * @return string */ - public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') + protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); @@ -233,7 +233,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the new table name * @return string */ - public function _rename_table($table_name, $new_table_name) + protected function _rename_table($table_name, $new_table_name) { return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); } diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index e1332ba93..7a3a41f2c 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -144,7 +144,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return array */ - public function _data_seek($n = 0) + protected function _data_seek($n = 0) { //Set the row count to 0 $this->num_rows = 0; @@ -162,7 +162,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return array */ - public function _fetch_assoc() + protected function _fetch_assoc() { //Increment row count $this->num_rows++; @@ -179,7 +179,7 @@ class CI_DB_interbase_result extends CI_DB_result { * * @return object */ - public function _fetch_object() + protected function _fetch_object() { //Increment row count $this->num_rows++; -- cgit v1.2.3-24-g4f1b From 2da66edce7c249c0305153a65c4292311f49a546 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 17:54:39 -0500 Subject: Fix counting issue, minor formatting --- .../database/drivers/interbase/interbase_forge.php | 2 +- .../drivers/interbase/interbase_result.php | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index c7372a0bf..d21a5551b 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -79,7 +79,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $sql = 'CREATE TABLE '; - $sql .= $this->db->_escape_identifiers($table)."("; + $sql .= $this->db->_protect_identifiers($table)."("; $current_field_count = 0; foreach ($fields as $field=>$attributes) diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 7a3a41f2c..9caf1ce91 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -82,7 +82,7 @@ class CI_DB_interbase_result extends CI_DB_result { public function list_fields() { $field_names = array(); - for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) + for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); $field_names[] = $info['name']; @@ -104,7 +104,7 @@ class CI_DB_interbase_result extends CI_DB_result { { $retval = array(); - for ($i = 0, $num_fields=$this->num_fields(); $i < $num_fields; $i++) + for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++) { $info = ibase_field_info($this->result_id, $i); @@ -164,10 +164,13 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_assoc() { - //Increment row count - $this->num_rows++; + if(($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + { + //Increment row count + $this->num_rows++; + } - return @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS); + return $row; } // -------------------------------------------------------------------- @@ -181,10 +184,13 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_object() { - //Increment row count - $this->num_rows++; + if(($row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + { + //Increment row count + $this->num_rows++; + } - return @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS); + return $row; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 41a439bf75bdd277e153d44788b732cf2e8c7ee3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 18:40:00 -0500 Subject: Minor formatting fixes --- system/database/drivers/interbase/interbase_result.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 9caf1ce91..01f0e52b2 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -164,7 +164,7 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_assoc() { - if(($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + if (($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) { //Increment row count $this->num_rows++; @@ -184,7 +184,7 @@ class CI_DB_interbase_result extends CI_DB_result { */ protected function _fetch_object() { - if(($row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) + if (($row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) { //Increment row count $this->num_rows++; @@ -209,7 +209,7 @@ class CI_DB_interbase_result extends CI_DB_result { // Convert result array to object so that // We don't have to get the result again - if(count($this->result_array) > 0) + if (count($this->result_array) > 0) { $i = 0; @@ -261,7 +261,7 @@ class CI_DB_interbase_result extends CI_DB_result { // Since the object and array are really similar, just case // the result object to an array if need be - if(count($this->result_object) > 0) + if (count($this->result_object) > 0) { foreach($this->result_object as $obj) { -- cgit v1.2.3-24-g4f1b From dd044b317fc2db52f3812792a256497a2f0e94fb Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 18:58:24 -0500 Subject: More style fixes, replaced _protect_identifiers with protect_identifiers in db_forge --- system/database/drivers/interbase/interbase_forge.php | 16 ++++++++-------- system/database/drivers/interbase/interbase_result.php | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index d21a5551b..b8ea6a05d 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -79,7 +79,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $sql = 'CREATE TABLE '; - $sql .= $this->db->_protect_identifiers($table)."("; + $sql .= $this->db->protect_identifiers($table)."("; $current_field_count = 0; foreach ($fields as $field=>$attributes) @@ -95,7 +95,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->_protect_identifiers($field); + $sql .= "\n\t".$this->db->protect_identifiers($field); $sql .= ' '.$attributes['TYPE']; @@ -138,7 +138,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + $primary_keys = $this->db->protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } @@ -148,11 +148,11 @@ class CI_DB_interbase_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { - $key = array($this->db->_protect_identifiers($key)); + $key = array($this->db->protect_identifiers($key)); } $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")"; @@ -195,7 +195,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { */ protected function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name); + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table)." $alter_type ".$this->db->protect_identifiers($column_name); $sql .= " {$column_definition}"; @@ -215,7 +215,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { if ($after_field != '') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + $sql .= ' AFTER ' . $this->db->protect_identifiers($after_field); } return $sql; @@ -235,7 +235,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { */ protected function _rename_table($table_name, $new_table_name) { - return 'ALTER TABLE '.$this->db->_protect_identifiers($table_name).' RENAME TO '.$this->db->_protect_identifiers($new_table_name); + return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); } } diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 01f0e52b2..be9cb6547 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -213,11 +213,11 @@ class CI_DB_interbase_result extends CI_DB_result { { $i = 0; - foreach($this->result_array as $array) + foreach ($this->result_array as $array) { $this->result_object[$i] = new StdClass(); - foreach($array as $key => $val) + foreach ($array as $key => $val) { $this->result_object[$i]->{$key} = $val; } @@ -263,7 +263,7 @@ class CI_DB_interbase_result extends CI_DB_result { // the result object to an array if need be if (count($this->result_object) > 0) { - foreach($this->result_object as $obj) + foreach ($this->result_object as $obj) { $this->result_array[] = (array)$obj; } -- cgit v1.2.3-24-g4f1b From 2062a8693e1ba44c4530254f63c3936894aad526 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 20 Feb 2012 19:38:10 -0500 Subject: Made tranaaction functions return their actual value --- system/database/drivers/interbase/interbase_driver.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index ba4f9d8d9..7258e605e 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -224,9 +224,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_commit($this->trans); - - return TRUE; + return @ibase_commit($this->trans); } // -------------------------------------------------------------------- @@ -249,9 +247,7 @@ class CI_DB_interbase_driver extends CI_DB { return TRUE; } - @ibase_rollback($this->trans); - - return TRUE; + return @ibase_rollback($this->trans); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 125fe732c09f82a0702f29c9309f726bdd5a33c3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 21 Feb 2012 07:58:25 -0500 Subject: More formatting fixes --- system/database/drivers/interbase/interbase_driver.php | 4 ++-- system/database/drivers/interbase/interbase_forge.php | 2 +- system/database/drivers/interbase/interbase_result.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system/database/drivers/interbase') 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 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 33038ad80..b49d1fa74 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -139,6 +139,9 @@ class CI_DB_interbase_driver extends CI_DB { if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) { $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); + + // Don't keep the service open + ibase_service_detach($service); return $version; } diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index e31021acb..76a0497c1 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -90,14 +90,24 @@ class CI_DB_interbase_utility extends CI_DB_utility { /** * Interbase/Firebird Export * - * @param array Preferences + * @param string $filename * @return mixed */ - public function _backup($params = array()) + public function backup($filename) { - // Currently unsupported - // @todo See if can be implemented - return $this->db->display_error('db_unsuported_feature'); + if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password)) + { + $res = ibase_backup($service, $this->db->database, $filename.'.fbk'); + + //Close the service connection + ibase_service_detach($service); + + return $res; + } + else + { + return FALSE; + } } } -- cgit v1.2.3-24-g4f1b From 56784f67c35c75b706c5f9fc2950e58356e7ecec Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 29 Feb 2012 11:58:20 -0500 Subject: Finally figured out limit statement --- .../drivers/interbase/interbase_driver.php | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/interbase') 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 9a96082726feadadd50aef1287b4e0df61414c0d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 29 Feb 2012 22:53:35 -0500 Subject: Fix 'skip' section of limit clause --- system/database/drivers/interbase/interbase_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/interbase') 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 00df2e3183dc1cbef82dafe6cc432d73fe659ae9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 18:37:16 +0200 Subject: Replace Interbase _error_message(), _error_number() with the new error() method --- .../drivers/interbase/interbase_driver.php | 48 +++++++++------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'system/database/drivers/interbase') 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 78ca39bc8c4b7edf0468e4a0a7251f808f352414 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Mar 2012 19:04:31 +0200 Subject: Removed db_set_charset() from Interbase driver (no longer needed) --- system/database/drivers/interbase/interbase_driver.php | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'system/database/drivers/interbase') 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 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/drivers/interbase/interbase_driver.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'system/database/drivers/interbase') 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; -- 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/drivers/interbase/interbase_driver.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'system/database/drivers/interbase') 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; -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/database/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 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system/database/drivers/interbase') diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index f4bd9e271..3e2ca4955 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 023d278ce..f46043569 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php index 4b15eee20..5bf0c902d 100644 --- a/system/database/drivers/interbase/interbase_result.php +++ b/system/database/drivers/interbase/interbase_result.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php index 76a0497c1..a88055ee0 100644 --- a/system/database/drivers/interbase/interbase_utility.php +++ b/system/database/drivers/interbase/interbase_utility.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b