From 69edc4368d6c6588936b3b6c8bcb9d36626d363a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 4 Dec 2012 13:32:16 +0200 Subject: Rename DB_result _data_seek() to data_seek() and make it publicly available (as requested in #2050) --- system/database/drivers/oci8/oci8_result.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/oci8') diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 7d5bf5172..661ea4944 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -240,8 +240,13 @@ class CI_DB_oci8_result extends CI_DB_result { * @param int $n (ignored) * @return bool */ - protected function _data_seek($n = 0) + public function data_seek($n = 0) { + if ($n > 0) + { + return FALSE; + } + /* The PHP manual says that if OCI_NO_AUTO_COMMIT mode * is used, and oci_rollback() and/or oci_commit() are * not subsequently called - this will cause an unnecessary -- cgit v1.2.3-24-g4f1b From fd24adf31255822d6aa9a5d2dce9010ad2ee4cf0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 4 Dec 2012 17:38:59 +0200 Subject: Remove CI_DB_oci8_result::data_seek() It can only call oci_execute() in order to reset the pointer to 0, the oci8 driver doesn't support setting the pointer. Due to the result_object(), result_array() and custom_result_object() calling data_seek() every time prior to fetching the result set, this only causes the query to be executed twice. All of the three methods now cast from existing result_object and/or result_array sets, so the probability to ever need to really fetch the result set again is practically zero and so this method doesn't bring any benefit. --- system/database/drivers/oci8/oci8_result.php | 63 ---------------------------- 1 file changed, 63 deletions(-) (limited to 'system/database/drivers/oci8') diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 661ea4944..84d46f82a 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -216,69 +216,6 @@ class CI_DB_oci8_result extends CI_DB_result { return $class_name; } - // -------------------------------------------------------------------- - - /** - * 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. - * - * Oracle's PHP extension doesn't have an easy way of doing this - * and the only workaround is to (re)execute the statement or cursor - * in order to go to the first (zero) index of the result set. - * Then, we would need to "dummy" fetch ($n - 1) rows to get to the - * right one. - * - * This is as ridiculous as it sounds and it's the reason why every - * other method that is fetching data tries to use an already "cached" - * result set. Keeping this just in case it becomes needed at - * some point in the future, but it will only work for resetting the - * pointer to zero. - * - * @param int $n (ignored) - * @return bool - */ - public function data_seek($n = 0) - { - if ($n > 0) - { - return FALSE; - } - - /* The PHP manual says that if OCI_NO_AUTO_COMMIT mode - * is used, and oci_rollback() and/or oci_commit() are - * not subsequently called - this will cause an unnecessary - * rollback to be triggered at the end of the script execution. - * - * Therefore we'll try to avoid using that mode flag - * if we're not currently in the middle of a transaction. - */ - if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS) - { - $result = @oci_execute($this->stmt_id, $this->commit_mode); - } - else - { - $result = @oci_execute($this->stmt_id); - } - - if ($result && $this->curs_id) - { - if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS) - { - return @oci_execute($this->curs_id, $this->commit_mode); - } - else - { - return @oci_execute($this->curs_id); - } - } - - return $result; - } - } /* End of file oci8_result.php */ -- cgit v1.2.3-24-g4f1b