From 37f4b9caa02783e06dd7c5318200113409a0deb1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:56:50 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- system/database/drivers/oci8/oci8_driver.php | 138 +++++++++++++-------------- 1 file changed, 69 insertions(+), 69 deletions(-) (limited to 'system/database/drivers/oci8/oci8_driver.php') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 3a05ce36c..14df104ff 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -1,4 +1,4 @@ - format - * value no the value of the parameter. If this is an OUT or IN OUT parameter, + * value no the value of the parameter. If this is an OUT or IN OUT parameter, * this should be a reference to a variable * type yes the type of the parameter * length yes the max size of the parameter @@ -275,8 +275,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * Bind parameters * - * @access private - * @return none + * @access private + * @return none */ function _bind_params($params) { @@ -386,10 +386,10 @@ class CI_DB_oci8_driver extends CI_DB { /** * Escape String * - * @access public - * @param string + * @access public + * @param string * @param bool whether or not the string will be used in a LIKE condition - * @return string + * @return string */ function escape_str($str, $like = FALSE) { @@ -421,8 +421,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * Affected Rows * - * @access public - * @return integer + * @access public + * @return integer */ function affected_rows() { @@ -434,8 +434,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * Insert ID * - * @access public - * @return integer + * @access public + * @return integer */ function insert_id() { @@ -451,9 +451,9 @@ class CI_DB_oci8_driver extends CI_DB { * Generates a platform-specific query string that counts all records in * the specified database * - * @access public - * @param string - * @return string + * @access public + * @param string + * @return string */ function count_all($table = '') { @@ -480,9 +480,9 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private + * @access private * @param boolean - * @return string + * @return string */ function _list_tables($prefix_limit = FALSE) { @@ -503,9 +503,9 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public - * @param string the table name - * @return string + * @access public + * @param string the table name + * @return string */ function _list_columns($table = '') { @@ -519,9 +519,9 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query so that the column data can be retrieved * - * @access public - * @param string the table name - * @return object + * @access public + * @param string the table name + * @return object */ function _field_data($table) { @@ -533,8 +533,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message string * - * @access private - * @return string + * @access private + * @return string */ function _error_message() { @@ -547,8 +547,8 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message number * - * @access private - * @return integer + * @access private + * @return integer */ function _error_number() { @@ -627,11 +627,11 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ function _insert($table, $keys, $values) { @@ -732,11 +732,11 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public - * @param string the sql query string - * @param integer the number of rows to limit the query to - * @param integer the offset value - * @return string + * @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) { @@ -759,9 +759,9 @@ class CI_DB_oci8_driver extends CI_DB { /** * Close DB Connection * - * @access public - * @param resource - * @return void + * @access public + * @param resource + * @return void */ function _close($conn_id) { -- cgit v1.2.3-24-g4f1b From 3e1df1abe203db8c07ffbd9096aec77c458b80d5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 7 Oct 2011 21:04:58 +0300 Subject: Cleanup and migrate oci8_driver and oci8_result from deprecated PHP4 to PHP5 style functions --- system/database/drivers/oci8/oci8_driver.php | 144 ++++++++++++++++----------- 1 file changed, 87 insertions(+), 57 deletions(-) (limited to 'system/database/drivers/oci8/oci8_driver.php') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 14df104ff..985466a79 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -35,8 +35,6 @@ * This is a modification of the DB_driver class to * permit access to oracle databases * - * NOTE: this uses the PHP 4 oci methods - * * @author Kelly McArdle * */ @@ -77,9 +75,9 @@ class CI_DB_oci8_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_connect() + public function db_connect() { - return @ocilogon($this->username, $this->password, $this->hostname); + return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set); } // -------------------------------------------------------------------- @@ -90,9 +88,9 @@ class CI_DB_oci8_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_pconnect() + public function db_pconnect() { - return @ociplogon($this->username, $this->password, $this->hostname); + return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set); } // -------------------------------------------------------------------- @@ -106,9 +104,10 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @return void */ - function reconnect() + public function reconnect() { // not implemented in oracle + return; } // -------------------------------------------------------------------- @@ -119,8 +118,9 @@ class CI_DB_oci8_driver extends CI_DB { * @access private called by the base class * @return resource */ - function db_select() + public function db_select() { + // Not in Oracle - schemas are actually usernames return TRUE; } @@ -134,7 +134,7 @@ class CI_DB_oci8_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; @@ -148,9 +148,9 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @return string */ - function _version() + public function _version() { - return ociserverversion($this->conn_id); + return oci_server_version($this->conn_id); } // -------------------------------------------------------------------- @@ -158,18 +158,18 @@ class CI_DB_oci8_driver extends CI_DB { /** * Execute the query * - * @access private called by the base class + * @access public called by the base class * @param string an SQL query * @return resource */ - function _execute($sql) + public function _execute($sql) { // oracle must parse the query before it is run. All of the actions with // the query are based on the statement id returned by ociparse $this->stmt_id = FALSE; $this->_set_stmt_id($sql); - ocisetprefetch($this->stmt_id, 1000); - return @ociexecute($this->stmt_id, $this->_commit); + oci_set_prefetch($this->stmt_id, 1000); + return @oci_execute($this->stmt_id, $this->_commit); } /** @@ -179,11 +179,11 @@ class CI_DB_oci8_driver extends CI_DB { * @param string an SQL query * @return none */ - function _set_stmt_id($sql) + private function _set_stmt_id($sql) { if ( ! is_resource($this->stmt_id)) { - $this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql)); + $this->stmt_id = oci_parse($this->conn_id, $this->_prep_query($sql)); } } @@ -198,7 +198,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param string an SQL query * @return string */ - function _prep_query($sql) + private function _prep_query($sql) { return $sql; } @@ -211,9 +211,9 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @return cursor id */ - function get_cursor() + public function get_cursor() { - $this->curs_id = ocinewcursor($this->conn_id); + $this->curs_id = oci_new_cursor($this->conn_id); return $this->curs_id; } @@ -237,7 +237,7 @@ class CI_DB_oci8_driver extends CI_DB { * type yes the type of the parameter * length yes the max size of the parameter */ - function stored_procedure($package, $procedure, $params) + public function stored_procedure($package, $procedure, $params) { if ($package == '' OR $procedure == '' OR ! is_array($params)) { @@ -257,7 +257,7 @@ class CI_DB_oci8_driver extends CI_DB { { $sql .= $param['name'] . ","; - if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR)) + if (array_key_exists('type', $param) && ($param['type'] === OCI_B_CURSOR)) { $have_cursor = TRUE; } @@ -278,7 +278,7 @@ class CI_DB_oci8_driver extends CI_DB { * @access private * @return none */ - function _bind_params($params) + private function _bind_params($params) { if ( ! is_array($params) OR ! is_resource($this->stmt_id)) { @@ -295,7 +295,7 @@ class CI_DB_oci8_driver extends CI_DB { } } - ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']); + oci_bind_by_name($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']); } } @@ -307,7 +307,7 @@ class CI_DB_oci8_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) { @@ -337,7 +337,7 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @return bool */ - function trans_commit() + public function trans_commit() { if ( ! $this->trans_enabled) { @@ -350,7 +350,7 @@ class CI_DB_oci8_driver extends CI_DB { return TRUE; } - $ret = OCIcommit($this->conn_id); + $ret = oci_commit($this->conn_id); $this->_commit = OCI_COMMIT_ON_SUCCESS; return $ret; } @@ -363,7 +363,7 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @return bool */ - function trans_rollback() + public function trans_rollback() { if ( ! $this->trans_enabled) { @@ -376,7 +376,7 @@ class CI_DB_oci8_driver extends CI_DB { return TRUE; } - $ret = OCIrollback($this->conn_id); + $ret = oci_rollback($this->conn_id); $this->_commit = OCI_COMMIT_ON_SUCCESS; return $ret; } @@ -391,7 +391,7 @@ class CI_DB_oci8_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)) { @@ -424,9 +424,9 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @return integer */ - function affected_rows() + public function affected_rows() { - return @ocirowcount($this->stmt_id); + return @oci_num_rows($this->stmt_id); } // -------------------------------------------------------------------- @@ -437,7 +437,7 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @return integer */ - function insert_id() + public function insert_id() { // not supported in oracle return $this->display_error('db_unsupported_function'); @@ -455,7 +455,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param string * @return string */ - function count_all($table = '') + public function count_all($table = '') { if ($table == '') { @@ -480,11 +480,11 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access private + * @access public * @param boolean - * @return string + * @return string */ - function _list_tables($prefix_limit = FALSE) + public function _list_tables($prefix_limit = FALSE) { $sql = "SELECT TABLE_NAME FROM ALL_TABLES"; @@ -507,7 +507,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param string the table name * @return string */ - function _list_columns($table = '') + public function _list_columns($table = '') { return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'"; } @@ -523,7 +523,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param string the table name * @return object */ - function _field_data($table) + public function _field_data($table) { return "SELECT * FROM ".$table." where rownum = 1"; } @@ -533,12 +533,13 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message string * - * @access private + * @access public * @return string */ - function _error_message() + public function _error_message() { - $error = ocierror($this->conn_id); + // If the error was during connection, no conn_id should be passed + $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); return $error['message']; } @@ -547,12 +548,13 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message number * - * @access private + * @access public * @return integer */ - function _error_number() + public function _error_number() { - $error = ocierror($this->conn_id); + // Same as _error_message() + $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); return $error['code']; } @@ -563,11 +565,11 @@ class CI_DB_oci8_driver extends CI_DB { * * This function escapes column and table names * - * @access private + * @access public * @param string * @return string */ - function _escape_identifiers($item) + public function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -610,7 +612,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param type * @return type */ - function _from_tables($tables) + public function _from_tables($tables) { if ( ! is_array($tables)) { @@ -633,9 +635,37 @@ class CI_DB_oci8_driver extends CI_DB { * @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).")"; + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + } + + // -------------------------------------------------------------------- + + /** + * Insert_batch 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 + */ + public function _insert_batch($table, $keys, $values) + { + $keys = implode(', ', $keys); + $sql = "INSERT ALL\n"; + + for ($i = 0, $c = count($values); $i < $c; $i++) + { + $sql .= ' INTO ' . $table . ' (' . $keys . ') VALUES ' . $values[$i] . "\n"; + } + + $sql .= 'SELECT * FROM dual'; + + return $sql; } // -------------------------------------------------------------------- @@ -653,7 +683,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param array the limit clause * @return string */ - function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + public function _update($table, $values, $where, $orderby = array(), $limit = FALSE) { foreach ($values as $key => $val) { @@ -686,7 +716,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param string the table name * @return string */ - function _truncate($table) + public function _truncate($table) { return "TRUNCATE TABLE ".$table; } @@ -704,7 +734,7 @@ class CI_DB_oci8_driver extends CI_DB { * @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 = ''; @@ -738,7 +768,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param integer the offset value * @return string */ - function _limit($sql, $limit, $offset) + public function _limit($sql, $limit, $offset) { $limit = $offset + $limit; $newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)"; @@ -763,9 +793,9 @@ class CI_DB_oci8_driver extends CI_DB { * @param resource * @return void */ - function _close($conn_id) + public function _close($conn_id) { - @ocilogoff($conn_id); + @oci_close($conn_id); } @@ -774,4 +804,4 @@ class CI_DB_oci8_driver extends CI_DB { /* End of file oci8_driver.php */ -/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file +/* Location: ./system/database/drivers/oci8/oci8_driver.php */ -- cgit v1.2.3-24-g4f1b From cfe49186f26cd7bb6410abd4f1069b49325dc0e9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Oct 2011 09:44:48 +0300 Subject: Some public and protected method declarations --- system/database/drivers/oci8/oci8_driver.php | 60 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'system/database/drivers/oci8/oci8_driver.php') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 985466a79..b4da3e965 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -145,10 +145,10 @@ class CI_DB_oci8_driver extends CI_DB { /** * Version number query string * - * @access public + * @access protected * @return string */ - public function _version() + protected function _version() { return oci_server_version($this->conn_id); } @@ -158,11 +158,11 @@ class CI_DB_oci8_driver extends CI_DB { /** * Execute the query * - * @access public called by the base class + * @access protected called by the base class * @param string an SQL query * @return resource */ - public function _execute($sql) + protected function _execute($sql) { // oracle must parse the query before it is run. All of the actions with // the query are based on the statement id returned by ociparse @@ -480,11 +480,11 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the table names can be fetched * - * @access public + * @access protected * @param boolean * @return string */ - public function _list_tables($prefix_limit = FALSE) + protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT TABLE_NAME FROM ALL_TABLES"; @@ -503,11 +503,11 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific query string so that the column names can be fetched * - * @access public + * @access protected * @param string the table name * @return string */ - public function _list_columns($table = '') + protected function _list_columns($table = '') { return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'"; } @@ -523,7 +523,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param string the table name * @return object */ - public function _field_data($table) + protected function _field_data($table) { return "SELECT * FROM ".$table." where rownum = 1"; } @@ -533,10 +533,10 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message string * - * @access public + * @access protected * @return string */ - public function _error_message() + protected function _error_message() { // If the error was during connection, no conn_id should be passed $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); @@ -548,10 +548,10 @@ class CI_DB_oci8_driver extends CI_DB { /** * The error message number * - * @access public + * @access protected * @return integer */ - public function _error_number() + protected function _error_number() { // Same as _error_message() $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); @@ -565,11 +565,11 @@ class CI_DB_oci8_driver extends CI_DB { * * This function escapes column and table names * - * @access public + * @access protected * @param string * @return string */ - public function _escape_identifiers($item) + protected function _escape_identifiers($item) { if ($this->_escape_char == '') { @@ -608,11 +608,11 @@ class CI_DB_oci8_driver extends CI_DB { * This function implicitly groups FROM tables so there is no confusion * about operator precedence in harmony with SQL standards * - * @access public + * @access protected * @param type * @return type */ - public function _from_tables($tables) + protected function _from_tables($tables) { if ( ! is_array($tables)) { @@ -635,7 +635,7 @@ class CI_DB_oci8_driver extends CI_DB { * @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).")"; } @@ -647,13 +647,13 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific insert string from the supplied data * - * @access public + * @access protected * @param string the table name * @param array the insert keys * @param array the insert values * @return string */ - public function _insert_batch($table, $keys, $values) + protected function _insert_batch($table, $keys, $values) { $keys = implode(', ', $keys); $sql = "INSERT ALL\n"; @@ -675,7 +675,7 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific update string from the supplied data * - * @access public + * @access protected * @param string the table name * @param array the update data * @param array the where clause @@ -683,7 +683,7 @@ class CI_DB_oci8_driver extends CI_DB { * @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) { @@ -712,11 +712,11 @@ class CI_DB_oci8_driver extends CI_DB { * If the database does not support the truncate() command * This function maps to "DELETE FROM table" * - * @access public + * @access protected * @param string the table name * @return string */ - public function _truncate($table) + protected function _truncate($table) { return "TRUNCATE TABLE ".$table; } @@ -728,13 +728,13 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific delete string from the supplied data * - * @access public + * @access protected * @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) + protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -762,13 +762,13 @@ class CI_DB_oci8_driver extends CI_DB { * * Generates a platform-specific LIMIT clause * - * @access public + * @access protected * @param string the sql query string * @param integer the number of rows to limit the query to * @param integer the offset value * @return string */ - public function _limit($sql, $limit, $offset) + protected function _limit($sql, $limit, $offset) { $limit = $offset + $limit; $newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)"; @@ -789,11 +789,11 @@ class CI_DB_oci8_driver extends CI_DB { /** * Close DB Connection * - * @access public + * @access protected * @param resource * @return void */ - public function _close($conn_id) + protected function _close($conn_id) { @oci_close($conn_id); } -- cgit v1.2.3-24-g4f1b From 448148b0d8ed1459662cfe501197686b8a48b609 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sat, 20 Aug 2011 14:23:14 -0500 Subject: Fixed a bug (#200) where MySQL queries would be malformed after calling db->count_all() then db->get() --- system/database/drivers/oci8/oci8_driver.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system/database/drivers/oci8/oci8_driver.php') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index b4da3e965..930177e62 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -470,6 +470,7 @@ class CI_DB_oci8_driver extends CI_DB { } $row = $query->row(); + $this->_reset_select(); return (int) $row->numrows; } -- cgit v1.2.3-24-g4f1b