blob: 7781b5bbd5019880d4c45ca42782631975c3a752 [file] [log] [blame]
Andrey Andreev24abcb92012-01-05 20:40:15 +02001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreev24abcb92012-01-05 20:40:15 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreev24abcb92012-01-05 20:40:15 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -050011 * This source file is subject to the Open Software License (OSL 3.0) that is
Andrey Andreev342a4662012-01-24 15:24:00 +020012 * bundled with this package in the files license.txt / license.rst. It is
Derek Jonesf4a4bd82011-10-20 12:18:42 -050013 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Barry Mienydd671972010-10-04 16:33:58 +020019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
Greg Aker0defe5d2012-01-01 18:46:41 -060021 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
Derek Jonesf4a4bd82011-10-20 12:18:42 -050022 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
Barry Mienydd671972010-10-04 16:33:58 +020024 * @since Version 1.0
Derek Allard2067d1a2008-11-13 22:59:24 +000025 * @filesource
26 */
27
Derek Allard2067d1a2008-11-13 22:59:24 +000028/**
29 * oci8 Result Class
30 *
31 * This class extends the parent result class: CI_DB_result
32 *
33 * @category Database
Derek Jonesf4a4bd82011-10-20 12:18:42 -050034 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000035 * @link http://codeigniter.com/user_guide/database/
36 */
37class CI_DB_oci8_result extends CI_DB_result {
38
Andrey Andreev24abcb92012-01-05 20:40:15 +020039 public $stmt_id;
40 public $curs_id;
41 public $limit_used;
42
43 // This will be changed by CI_DB_driver, but it's good to have a default:
44 public $commit_mode = OCI_DEFAULT;
45
46 /* Overwriting the parent here, so we have a way to know if it's
47 * already called or not:
48 */
49 public $num_rows;
Derek Allard2067d1a2008-11-13 22:59:24 +000050
51 /**
52 * Number of rows in the result set.
53 *
Andrey Andreev24abcb92012-01-05 20:40:15 +020054 * Oracle doesn't have a graceful way to return the number of rows
Derek Allard2067d1a2008-11-13 22:59:24 +000055 * so we have to use what amounts to a hack.
Barry Mienydd671972010-10-04 16:33:58 +020056 *
Andrey Andreevaa786c92012-01-16 12:14:45 +020057 * @return int
Derek Allard2067d1a2008-11-13 22:59:24 +000058 */
Andrey Andreev5c3a2022011-10-07 21:04:58 +030059 public function num_rows()
Derek Allard2067d1a2008-11-13 22:59:24 +000060 {
Andrey Andreev24abcb92012-01-05 20:40:15 +020061 if ( ! is_int($this->num_rows))
Derek Allard2067d1a2008-11-13 22:59:24 +000062 {
Andrey Andreev24abcb92012-01-05 20:40:15 +020063 if (count($this->result_array) > 0)
Andrey Andreevef3e2402011-09-21 14:39:29 +030064 {
Andrey Andreev24abcb92012-01-05 20:40:15 +020065 return $this->num_rows = count($this->result_array);
Andrey Andreevef3e2402011-09-21 14:39:29 +030066 }
Andrey Andreev24abcb92012-01-05 20:40:15 +020067 elseif (count($this->result_object) > 0)
68 {
Andrey Andreevb5e6f112012-01-16 13:25:07 +020069 return $this->num_rows = count($this->result_object);
Andrey Andreev24abcb92012-01-05 20:40:15 +020070 }
71
72 return $this->num_rows = count($this->result_array());
Derek Allard2067d1a2008-11-13 22:59:24 +000073 }
74
Andrey Andreevef3e2402011-09-21 14:39:29 +030075 return $this->num_rows;
Derek Allard2067d1a2008-11-13 22:59:24 +000076 }
77
78 // --------------------------------------------------------------------
79
80 /**
81 * Number of fields in the result set
82 *
Andrey Andreevaa786c92012-01-16 12:14:45 +020083 * @return int
Derek Allard2067d1a2008-11-13 22:59:24 +000084 */
Andrey Andreev5c3a2022011-10-07 21:04:58 +030085 public function num_fields()
Derek Allard2067d1a2008-11-13 22:59:24 +000086 {
Andrey Andreev5c3a2022011-10-07 21:04:58 +030087 $count = @oci_num_fields($this->stmt_id);
Derek Allard2067d1a2008-11-13 22:59:24 +000088
89 // if we used a limit we subtract it
Andrey Andreevaa786c92012-01-16 12:14:45 +020090 return ($this->limit_used) ? $count - 1 : $count;
Derek Allard2067d1a2008-11-13 22:59:24 +000091 }
92
93 // --------------------------------------------------------------------
94
95 /**
96 * Fetch Field Names
97 *
98 * Generates an array of column names
99 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000100 * @return array
101 */
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300102 public function list_fields()
Derek Allard2067d1a2008-11-13 22:59:24 +0000103 {
104 $field_names = array();
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300105 for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
Derek Allard2067d1a2008-11-13 22:59:24 +0000106 {
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300107 $field_names[] = oci_field_name($this->stmt_id, $c);
Derek Allard2067d1a2008-11-13 22:59:24 +0000108 }
109 return $field_names;
110 }
111
112 // --------------------------------------------------------------------
113
114 /**
115 * Field data
116 *
117 * Generates an array of objects containing field meta-data
118 *
Andrey Andreevaa786c92012-01-16 12:14:45 +0200119 * @return array
Derek Allard2067d1a2008-11-13 22:59:24 +0000120 */
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300121 public function field_data()
Derek Allard2067d1a2008-11-13 22:59:24 +0000122 {
123 $retval = array();
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300124 for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
Derek Allard2067d1a2008-11-13 22:59:24 +0000125 {
Andrey Andreevaa786c92012-01-16 12:14:45 +0200126 $F = new stdClass();
127 $F->name = oci_field_name($this->stmt_id, $c);
128 $F->type = oci_field_type($this->stmt_id, $c);
129 $F->max_length = oci_field_size($this->stmt_id, $c);
Derek Allard2067d1a2008-11-13 22:59:24 +0000130
131 $retval[] = $F;
132 }
133
134 return $retval;
135 }
136
137 // --------------------------------------------------------------------
138
139 /**
140 * Free the result
141 *
Andrey Andreev24abcb92012-01-05 20:40:15 +0200142 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200143 */
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300144 public function free_result()
Derek Allard2067d1a2008-11-13 22:59:24 +0000145 {
146 if (is_resource($this->result_id))
147 {
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300148 oci_free_statement($this->result_id);
Derek Allard2067d1a2008-11-13 22:59:24 +0000149 $this->result_id = FALSE;
150 }
Andrey Andreev24abcb92012-01-05 20:40:15 +0200151
152 if (is_resource($this->stmt_id))
153 {
154 oci_free_statement($this->stmt_id);
155 }
156
157 if (is_resource($this->curs_id))
158 {
159 oci_cancel($this->curs_id);
160 $this->curs_id = NULL;
161 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000162 }
163
164 // --------------------------------------------------------------------
165
166 /**
167 * Result - associative array
168 *
169 * Returns the result set as an array
170 *
Andrey Andreevaa786c92012-01-16 12:14:45 +0200171 * @return array
Derek Allard2067d1a2008-11-13 22:59:24 +0000172 */
Andrey Andreevbc95e472011-10-20 09:44:48 +0300173 protected function _fetch_assoc()
Derek Allard2067d1a2008-11-13 22:59:24 +0000174 {
175 $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300176 return oci_fetch_assoc($id);
Derek Allard2067d1a2008-11-13 22:59:24 +0000177 }
178
179 // --------------------------------------------------------------------
180
181 /**
182 * Result - object
183 *
184 * Returns the result set as an object
185 *
Andrey Andreevaa786c92012-01-16 12:14:45 +0200186 * @return object
Derek Allard2067d1a2008-11-13 22:59:24 +0000187 */
Andrey Andreevbc95e472011-10-20 09:44:48 +0300188 protected function _fetch_object()
Barry Mienydd671972010-10-04 16:33:58 +0200189 {
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300190 $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
Andrey Andreev24abcb92012-01-05 20:40:15 +0200191 return oci_fetch_object($id);
192 }
193
194 // --------------------------------------------------------------------
195
Derek Allard2067d1a2008-11-13 22:59:24 +0000196 /**
Andrey Andreeve35d7782012-01-19 15:56:20 +0200197 * Query result. Array version.
Derek Allard2067d1a2008-11-13 22:59:24 +0000198 *
Andrey Andreev24abcb92012-01-05 20:40:15 +0200199 * @return array
Derek Allard2067d1a2008-11-13 22:59:24 +0000200 */
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300201 public function result_array()
Derek Allard2067d1a2008-11-13 22:59:24 +0000202 {
203 if (count($this->result_array) > 0)
204 {
205 return $this->result_array;
206 }
Andrey Andreev24abcb92012-01-05 20:40:15 +0200207 elseif (count($this->result_object) > 0)
208 {
209 for ($i = 0, $c = count($this->result_object); $i < $c; $i++)
210 {
211 $this->result_array[$i] = (array) $this->result_object[$i];
212 }
213
214 return $this->result_array;
215 }
216 elseif (is_array($this->row_data))
217 {
218 if (count($this->row_data) === 0)
219 {
220 return $this->result_array;
221 }
222 else
223 {
224 $row_index = count($this->row_data);
225 }
226 }
227 else
228 {
229 $row_index = 0;
230 $this->row_data = array();
231 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000232
Derek Allard2067d1a2008-11-13 22:59:24 +0000233 $row = NULL;
Andrey Andreev5c3a2022011-10-07 21:04:58 +0300234 while ($row = $this->_fetch_assoc())
Derek Allard2067d1a2008-11-13 22:59:24 +0000235 {
Andrey Andreev24abcb92012-01-05 20:40:15 +0200236 $this->row_data[$row_index++] = $row;
Derek Allard2067d1a2008-11-13 22:59:24 +0000237 }
238
Andrey Andreev24abcb92012-01-05 20:40:15 +0200239 // Un-comment the following line, in case it becomes needed
240 // $this->_data_seek();
241 return $this->result_array = $this->row_data;
242 }
243
244 // --------------------------------------------------------------------
245
246 /**
247 * Query result. "object" version.
248 *
249 * @return array
250 */
251 public function result_object()
252 {
253 if (count($this->result_object) > 0)
254 {
255 return $this->result_object;
256 }
257 elseif (count($this->result_array) > 0)
258 {
259 for ($i = 0, $c = count($this->result_array); $i < $c; $i++)
260 {
261 $this->result_object[] = (object) $this->result_array[$i];
262 }
263
264 return $this->result_object;
265 }
266 elseif (is_array($this->row_data))
267 {
268 if (count($this->row_data) === 0)
269 {
270 return $this->result_object;
271 }
272 else
273 {
274 $row_index = count($this->row_data);
275 for ($i = 0; $i < $row_index; $i++)
276 {
277 $this->result_object[$i] = (object) $this->row_data[$i];
278 }
279 }
280 }
281 else
282 {
283 $row_index = 0;
284 $this->row_data = array();
285 }
286
287 $row = NULL;
288 while ($row = $this->_fetch_object())
289 {
290 $this->row_data[$row_index] = (array) $row;
291 $this->result_object[$row_index++] = $row;
292 }
293
294 // Un-comment the following line, in case it becomes needed
295 // $this->_data_seek();
296 return $this->result_object;
297 }
298
299 // --------------------------------------------------------------------
300
301 /**
302 * Query result. Custom object version.
303 *
304 * @param string class name used to instantiate rows to
305 * @return array
306 */
307 public function custom_result_object($class_name)
308 {
309 if (array_key_exists($class_name, $this->custom_result_object))
310 {
311 return $this->custom_result_object[$class_name];
312 }
313
314 if ( ! class_exists($class_name) OR $this->result_id === FALSE OR $this->num_rows() === 0)
315 {
316 return array();
317 }
318
Andrey Andreevb5e6f112012-01-16 13:25:07 +0200319 /* Even if we didn't have result_array or result_object
320 * set prior to custom_result_object() being called,
321 * num_rows() has already done so.
322 * Pass by reference, as we don't know how
Andrey Andreev24abcb92012-01-05 20:40:15 +0200323 * large it might be and we don't want 1000 row
324 * sets being copied.
325 */
326 if (count($this->result_array) > 0)
327 {
328 $data = &$this->result_array;
329 }
330 elseif (count($this->result_object) > 0)
331 {
332 $data = &$this->result_object;
333 }
334
Andrey Andreevb5e6f112012-01-16 13:25:07 +0200335 $result_object = array();
336 for ($i = 0, $c = count($data); $i < $c; $i++)
Andrey Andreev24abcb92012-01-05 20:40:15 +0200337 {
Andrey Andreevb5e6f112012-01-16 13:25:07 +0200338 $result_object[$i] = new $class_name();
339 foreach ($data[$i] as $key => $value)
Andrey Andreev24abcb92012-01-05 20:40:15 +0200340 {
Andrey Andreevb5e6f112012-01-16 13:25:07 +0200341 $result_object[$i]->$key = $value;
Andrey Andreev24abcb92012-01-05 20:40:15 +0200342 }
343 }
Andrey Andreev24abcb92012-01-05 20:40:15 +0200344
345 // Cache and return the array
346 return $this->custom_result_object[$class_name] = $result_object;
347 }
348
349 // --------------------------------------------------------------------
350
351 /* Single row result.
352 *
353 * Acts as a wrapper for row_object(), row_array()
354 * and custom_row_object(). Also used by first_row(), next_row()
355 * and previous_row().
356 *
357 * @param int row index
358 * @param string ('object', 'array' or a custom class name)
359 * @return mixed whatever was passed to the second parameter
360 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200361 public function row($n = 0, $type = 'object')
362 {
Andrey Andreevaa786c92012-01-16 12:14:45 +0200363 if ($type === 'object')
364 {
365 return $this->row_object($n);
366 }
367 elseif ($type === 'array')
368 {
369 return $this->row_array($n);
370 }
371
372 return $this->custom_row_object($n, $type);
Andrey Andreev24abcb92012-01-05 20:40:15 +0200373 }
374
375 // --------------------------------------------------------------------
376
377 /* Single row result. Array version.
378 *
379 * @param int row index
380 * @return array
381 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200382 public function row_array($n = 0)
383 {
384 // Make sure $n is not a string
385 if ( ! is_int($n))
386 {
387 $n = (int) $n;
388 }
389
390 /* If row_data is initialized, it means that we've already tried
391 * (at least) to fetch some data, so ... check if we already have
392 * this row.
393 */
394 if (is_array($this->row_data))
395 {
396 /* If we already have row_data[$n] - return it.
397 *
398 * If we enter the elseif, there's a number of reasons to
399 * return an empty array:
400 *
401 * - count($this->row_data) === 0 means there are no results
402 * - num_rows being set, result_array and/or result_object
403 * having count() > 0 means that we've already fetched all
404 * data and $n is greater than our highest row index available
405 * - $n < $this->current_row means that if such row existed,
406 * we would've already returned it, therefore $n is an
407 * invalid index
408 */
409 if (isset($this->row_data[$n])) // We already have this row
410 {
411 $this->current_row = $n;
412 return $this->row_data[$n];
413 }
414 elseif (count($this->row_data) === 0 OR is_int($this->num_rows)
415 OR count($this->result_array) > 0 OR count($this->result_object) > 0
416 OR $n < $this->current_row)
417 {
418 // No such row exists
419 return array();
420 }
421
422 // Get the next row index that would actually need to be fetched
423 $current_row = ($this->current_row < count($this->row_data)) ? count($this->row_data) : $this->current_row + 1;
424 }
425 else
426 {
427 $current_row = $this->current_row = 0;
428 $this->row_data = array();
429 }
430
431 /* Fetch more data, if available
432 *
433 * NOTE: Operator precedence is important here, if you change
434 * 'AND' with '&&' - it WILL BREAK the results, as
435 * $row will be assigned the scalar value of both
436 * expressions!
437 */
438 while ($row = $this->_fetch_assoc() AND $current_row <= $n)
439 {
440 $this->row_data[$current_row++] = $row;
441 }
442
443 // This would mean that there's no (more) data to fetch
444 if ( ! is_array($this->row_data) OR ! isset($this->row_data[$n]))
445 {
446 // Cache what we already have
447 if (is_array($this->row_data))
448 {
449 $this->num_rows = count($this->row_data);
450 /* Usually, row_data could have less elements than result_array,
451 * but at this point - they should be exactly the same.
452 */
453 $this->result_array = $this->row_data;
454 }
455 else
456 {
457 $this->num_rows = 0;
458 }
459
460 return array();
461 }
462
463 $this->current_row = $n;
464 return $this->row_data[$n];
465 }
466
467 // --------------------------------------------------------------------
468
469 /* Single row result. Object version.
470 *
471 * @param int row index
472 * @return mixed object if row found; empty array if not
473 */
474 public function row_object($n = 0)
475 {
476 // Make sure $n is not a string
477 if ( ! is_int($n))
478 {
479 $n = (int) $n;
480 }
481 /* Logic here is exactly the same as in row_array,
482 * except we have to cast row_data[$n] to an object.
483 *
484 * If we already have result_object though - we can
485 * directly return from it.
486 */
487 if (isset($this->result_object[$n]))
488 {
489 $this->current_row = $n;
490 // Set this, if not already done.
491 if ( ! is_int($this->num_rows))
492 {
493 $this->num_rows = count($this->result_object);
494 }
495
496 return $this->result_object[$n];
497 }
498
499 $row = $this->row_array($n);
500 // Cast only if the row exists
501 if (count($row) > 0)
502 {
503 $this->current_row = $n;
504 return (object) $row;
505 }
506
507 return array();
508 }
509
510 // --------------------------------------------------------------------
511
512 /* Single row result. Custom object version.
513 *
514 * @param int row index
515 * @param string custom class name
516 * @return mixed custom object if row found; empty array otherwise
517 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200518 public function custom_row_object($n = 0, $class_name)
519 {
520 // Make sure $n is not a string
521 if ( ! is_int($n))
522 {
523 $n = (int) $n;
524 }
525
526 if (array_key_exists($class_name, $this->custom_result_object))
527 {
528 /* We already have a the whole result set with this class_name,
529 * return the specified row if it exists, and an empty array if
530 * it doesn't.
531 */
532 if (isset($this->custom_result_object[$class_name][$n]))
533 {
534 $this->current_row = $n;
535 return $this->custom_result_object[$class_name][$n];
536 }
537 else
538 {
539 return array();
540 }
541 }
542 elseif ( ! class_exists($class_name)) // No such class exists
543 {
544 return array();
545 }
546
547 $row = $this->row_array($n);
548 // An array would mean that the row doesn't exist
549 if (is_array($row))
550 {
551 return $row;
552 }
553
554 // Convert to the desired class and return
555 $row_object = new $class_name();
556 foreach ($row as $key => $value)
557 {
558 $row_object->$key = $value;
559 }
560
561 $this->current_row = $n;
562 return $row_object;
563 }
564
565 // --------------------------------------------------------------------
566
567 /* First row result.
568 *
569 * @param string ('object', 'array' or a custom class name)
570 * @return mixed whatever was passed to the second parameter
571 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200572 public function first_row($type = 'object')
573 {
574 return $this->row(0, $type);
575 }
576
577 // --------------------------------------------------------------------
578
579 /* Last row result.
580 *
581 * @param string ('object', 'array' or a custom class name)
582 * @return mixed whatever was passed to the second parameter
583 */
584 public function last_row($type = 'object')
585 {
586 $result = &$this->result($type);
587 if ( ! isset($this->num_rows))
588 {
589 $this->num_rows = count($result);
590 }
591 $this->current_row = $this->num_rows - 1;
592 return $result[$this->current_row];
593 }
594
595 // --------------------------------------------------------------------
596
597 /* Next row result.
598 *
599 * @param string ('object', 'array' or a custom class name)
600 * @return mixed whatever was passed to the second parameter
601 */
602 public function next_row($type = 'object')
603 {
604 if (is_array($this->row_data))
605 {
606 $count = count($this->row_data);
607 if ($this->current_row > $count OR ($this->current_row === 0 && $count === 0))
608 {
609 $n = $count;
610 }
611 else
612 {
613 $n = $this->current_row + 1;
614 }
615 }
616 else
617 {
618 $n = 0;
619 }
620
621 return $this->row($n, $type);
622 }
623
624 // --------------------------------------------------------------------
625
626 /* Previous row result.
627 *
628 * @param string ('object', 'array' or a custom class name)
629 * @return mixed whatever was passed to the second parameter
630 */
631 public function previous_row($type = 'object')
632 {
633 $n = ($this->current_row !== 0) ? $this->current_row - 1 : 0;
634 return $this->row($n, $type);
Derek Allard2067d1a2008-11-13 22:59:24 +0000635 }
636
637 // --------------------------------------------------------------------
638
639 /**
640 * Data Seek
641 *
Andrey Andreev24abcb92012-01-05 20:40:15 +0200642 * Moves the internal pointer to the desired offset. We call
Derek Allard2067d1a2008-11-13 22:59:24 +0000643 * this internally before fetching results to make sure the
Andrey Andreev24abcb92012-01-05 20:40:15 +0200644 * result set starts at zero.
Derek Allard2067d1a2008-11-13 22:59:24 +0000645 *
Andrey Andreev24abcb92012-01-05 20:40:15 +0200646 * Oracle's PHP extension doesn't have an easy way of doing this
647 * and the only workaround is to (re)execute the statement or cursor
648 * in order to go to the first (zero) index of the result set.
649 * Then, we would need to "dummy" fetch ($n - 1) rows to get to the
650 * right one.
651 *
652 * This is as ridiculous as it sounds and it's the reason why every
653 * other method that is fetching data tries to use an already "cached"
654 * result set. Keeping this just in case it becomes needed at
655 * some point in the future, but it will only work for resetting the
656 * pointer to zero.
657 *
658 * @return bool
Derek Allard2067d1a2008-11-13 22:59:24 +0000659 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200660 protected function _data_seek()
Derek Allard2067d1a2008-11-13 22:59:24 +0000661 {
Andrey Andreev24abcb92012-01-05 20:40:15 +0200662 /* The PHP manual says that if OCI_NO_AUTO_COMMIT mode
663 * is used, and oci_rollback() and/or oci_commit() are
664 * not subsequently called - this will cause an unnecessary
665 * rollback to be triggered at the end of the script execution.
666 *
667 * Therefore we'll try to avoid using that mode flag
668 * if we're not currently in the middle of a transaction.
669 */
670 if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS)
671 {
672 $result = @oci_execute($this->stmt_id, $this->commit_mode);
673 }
674 else
675 {
676 $result = @oci_execute($this->stmt_id);
677 }
678
679 if ($result && $this->curs_id)
680 {
681 if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS)
682 {
683 return @oci_execute($this->curs_id, $this->commit_mode);
684 }
685 else
686 {
687 return @oci_execute($this->curs_id);
688 }
689 }
690
691 return $result;
Derek Allard2067d1a2008-11-13 22:59:24 +0000692 }
693
694}
695
Derek Allard2067d1a2008-11-13 22:59:24 +0000696/* End of file oci8_result.php */
Andrey Andreevef3e2402011-09-21 14:39:29 +0300697/* Location: ./system/database/drivers/oci8/oci8_result.php */