blob: e6e932175b673e3bf5ed17db8932b6c4bdda4d08 [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 Andreevaa786c92012-01-16 12:14:45 +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 Andreev24abcb92012-01-05 20:40:15 +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 */
361
362 public function row($n = 0, $type = 'object')
363 {
Andrey Andreevaa786c92012-01-16 12:14:45 +0200364 if ($type === 'object')
365 {
366 return $this->row_object($n);
367 }
368 elseif ($type === 'array')
369 {
370 return $this->row_array($n);
371 }
372
373 return $this->custom_row_object($n, $type);
Andrey Andreev24abcb92012-01-05 20:40:15 +0200374 }
375
376 // --------------------------------------------------------------------
377
378 /* Single row result. Array version.
379 *
380 * @param int row index
381 * @return array
382 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200383 public function row_array($n = 0)
384 {
385 // Make sure $n is not a string
386 if ( ! is_int($n))
387 {
388 $n = (int) $n;
389 }
390
391 /* If row_data is initialized, it means that we've already tried
392 * (at least) to fetch some data, so ... check if we already have
393 * this row.
394 */
395 if (is_array($this->row_data))
396 {
397 /* If we already have row_data[$n] - return it.
398 *
399 * If we enter the elseif, there's a number of reasons to
400 * return an empty array:
401 *
402 * - count($this->row_data) === 0 means there are no results
403 * - num_rows being set, result_array and/or result_object
404 * having count() > 0 means that we've already fetched all
405 * data and $n is greater than our highest row index available
406 * - $n < $this->current_row means that if such row existed,
407 * we would've already returned it, therefore $n is an
408 * invalid index
409 */
410 if (isset($this->row_data[$n])) // We already have this row
411 {
412 $this->current_row = $n;
413 return $this->row_data[$n];
414 }
415 elseif (count($this->row_data) === 0 OR is_int($this->num_rows)
416 OR count($this->result_array) > 0 OR count($this->result_object) > 0
417 OR $n < $this->current_row)
418 {
419 // No such row exists
420 return array();
421 }
422
423 // Get the next row index that would actually need to be fetched
424 $current_row = ($this->current_row < count($this->row_data)) ? count($this->row_data) : $this->current_row + 1;
425 }
426 else
427 {
428 $current_row = $this->current_row = 0;
429 $this->row_data = array();
430 }
431
432 /* Fetch more data, if available
433 *
434 * NOTE: Operator precedence is important here, if you change
435 * 'AND' with '&&' - it WILL BREAK the results, as
436 * $row will be assigned the scalar value of both
437 * expressions!
438 */
439 while ($row = $this->_fetch_assoc() AND $current_row <= $n)
440 {
441 $this->row_data[$current_row++] = $row;
442 }
443
444 // This would mean that there's no (more) data to fetch
445 if ( ! is_array($this->row_data) OR ! isset($this->row_data[$n]))
446 {
447 // Cache what we already have
448 if (is_array($this->row_data))
449 {
450 $this->num_rows = count($this->row_data);
451 /* Usually, row_data could have less elements than result_array,
452 * but at this point - they should be exactly the same.
453 */
454 $this->result_array = $this->row_data;
455 }
456 else
457 {
458 $this->num_rows = 0;
459 }
460
461 return array();
462 }
463
464 $this->current_row = $n;
465 return $this->row_data[$n];
466 }
467
468 // --------------------------------------------------------------------
469
470 /* Single row result. Object version.
471 *
472 * @param int row index
473 * @return mixed object if row found; empty array if not
474 */
475 public function row_object($n = 0)
476 {
477 // Make sure $n is not a string
478 if ( ! is_int($n))
479 {
480 $n = (int) $n;
481 }
482 /* Logic here is exactly the same as in row_array,
483 * except we have to cast row_data[$n] to an object.
484 *
485 * If we already have result_object though - we can
486 * directly return from it.
487 */
488 if (isset($this->result_object[$n]))
489 {
490 $this->current_row = $n;
491 // Set this, if not already done.
492 if ( ! is_int($this->num_rows))
493 {
494 $this->num_rows = count($this->result_object);
495 }
496
497 return $this->result_object[$n];
498 }
499
500 $row = $this->row_array($n);
501 // Cast only if the row exists
502 if (count($row) > 0)
503 {
504 $this->current_row = $n;
505 return (object) $row;
506 }
507
508 return array();
509 }
510
511 // --------------------------------------------------------------------
512
513 /* Single row result. Custom object version.
514 *
515 * @param int row index
516 * @param string custom class name
517 * @return mixed custom object if row found; empty array otherwise
518 */
519
520 public function custom_row_object($n = 0, $class_name)
521 {
522 // Make sure $n is not a string
523 if ( ! is_int($n))
524 {
525 $n = (int) $n;
526 }
527
528 if (array_key_exists($class_name, $this->custom_result_object))
529 {
530 /* We already have a the whole result set with this class_name,
531 * return the specified row if it exists, and an empty array if
532 * it doesn't.
533 */
534 if (isset($this->custom_result_object[$class_name][$n]))
535 {
536 $this->current_row = $n;
537 return $this->custom_result_object[$class_name][$n];
538 }
539 else
540 {
541 return array();
542 }
543 }
544 elseif ( ! class_exists($class_name)) // No such class exists
545 {
546 return array();
547 }
548
549 $row = $this->row_array($n);
550 // An array would mean that the row doesn't exist
551 if (is_array($row))
552 {
553 return $row;
554 }
555
556 // Convert to the desired class and return
557 $row_object = new $class_name();
558 foreach ($row as $key => $value)
559 {
560 $row_object->$key = $value;
561 }
562
563 $this->current_row = $n;
564 return $row_object;
565 }
566
567 // --------------------------------------------------------------------
568
569 /* First row result.
570 *
571 * @param string ('object', 'array' or a custom class name)
572 * @return mixed whatever was passed to the second parameter
573 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200574 public function first_row($type = 'object')
575 {
576 return $this->row(0, $type);
577 }
578
579 // --------------------------------------------------------------------
580
581 /* Last row result.
582 *
583 * @param string ('object', 'array' or a custom class name)
584 * @return mixed whatever was passed to the second parameter
585 */
586 public function last_row($type = 'object')
587 {
588 $result = &$this->result($type);
589 if ( ! isset($this->num_rows))
590 {
591 $this->num_rows = count($result);
592 }
593 $this->current_row = $this->num_rows - 1;
594 return $result[$this->current_row];
595 }
596
597 // --------------------------------------------------------------------
598
599 /* Next row result.
600 *
601 * @param string ('object', 'array' or a custom class name)
602 * @return mixed whatever was passed to the second parameter
603 */
604 public function next_row($type = 'object')
605 {
606 if (is_array($this->row_data))
607 {
608 $count = count($this->row_data);
609 if ($this->current_row > $count OR ($this->current_row === 0 && $count === 0))
610 {
611 $n = $count;
612 }
613 else
614 {
615 $n = $this->current_row + 1;
616 }
617 }
618 else
619 {
620 $n = 0;
621 }
622
623 return $this->row($n, $type);
624 }
625
626 // --------------------------------------------------------------------
627
628 /* Previous row result.
629 *
630 * @param string ('object', 'array' or a custom class name)
631 * @return mixed whatever was passed to the second parameter
632 */
633 public function previous_row($type = 'object')
634 {
635 $n = ($this->current_row !== 0) ? $this->current_row - 1 : 0;
636 return $this->row($n, $type);
Derek Allard2067d1a2008-11-13 22:59:24 +0000637 }
638
639 // --------------------------------------------------------------------
640
641 /**
642 * Data Seek
643 *
Andrey Andreev24abcb92012-01-05 20:40:15 +0200644 * Moves the internal pointer to the desired offset. We call
Derek Allard2067d1a2008-11-13 22:59:24 +0000645 * this internally before fetching results to make sure the
Andrey Andreev24abcb92012-01-05 20:40:15 +0200646 * result set starts at zero.
Derek Allard2067d1a2008-11-13 22:59:24 +0000647 *
Andrey Andreev24abcb92012-01-05 20:40:15 +0200648 * Oracle's PHP extension doesn't have an easy way of doing this
649 * and the only workaround is to (re)execute the statement or cursor
650 * in order to go to the first (zero) index of the result set.
651 * Then, we would need to "dummy" fetch ($n - 1) rows to get to the
652 * right one.
653 *
654 * This is as ridiculous as it sounds and it's the reason why every
655 * other method that is fetching data tries to use an already "cached"
656 * result set. Keeping this just in case it becomes needed at
657 * some point in the future, but it will only work for resetting the
658 * pointer to zero.
659 *
660 * @return bool
Derek Allard2067d1a2008-11-13 22:59:24 +0000661 */
Andrey Andreev24abcb92012-01-05 20:40:15 +0200662 protected function _data_seek()
Derek Allard2067d1a2008-11-13 22:59:24 +0000663 {
Andrey Andreev24abcb92012-01-05 20:40:15 +0200664 /* The PHP manual says that if OCI_NO_AUTO_COMMIT mode
665 * is used, and oci_rollback() and/or oci_commit() are
666 * not subsequently called - this will cause an unnecessary
667 * rollback to be triggered at the end of the script execution.
668 *
669 * Therefore we'll try to avoid using that mode flag
670 * if we're not currently in the middle of a transaction.
671 */
672 if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS)
673 {
674 $result = @oci_execute($this->stmt_id, $this->commit_mode);
675 }
676 else
677 {
678 $result = @oci_execute($this->stmt_id);
679 }
680
681 if ($result && $this->curs_id)
682 {
683 if ($this->commit_mode !== OCI_COMMIT_ON_SUCCESS)
684 {
685 return @oci_execute($this->curs_id, $this->commit_mode);
686 }
687 else
688 {
689 return @oci_execute($this->curs_id);
690 }
691 }
692
693 return $result;
Derek Allard2067d1a2008-11-13 22:59:24 +0000694 }
695
696}
697
Derek Allard2067d1a2008-11-13 22:59:24 +0000698/* End of file oci8_result.php */
Andrey Andreevef3e2402011-09-21 14:39:29 +0300699/* Location: ./system/database/drivers/oci8/oci8_result.php */