Subversion Repositories Web Services

Rev

Rev 118294 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
82190 hhl 1
<?php
111590 hhl 2
 
82190 hhl 3
/**
4
 *
5
 * This file is part of Open Library System.
6
 * Copyright © 2009, Dansk Bibliotekscenter a/s,
7
 * Tempovej 7-11, DK-2750 Ballerup, Denmark. CVR: 15149043
8
 *
9
 * Open Library System is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * Open Library System is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with Open Library System.  If not, see <http://www.gnu.org/licenses/>.
118294 fvs 21
 */
82190 hhl 22
 
23
 
24
/**
25
 * \brief Class for handling OCI
26
 *
27
 * Example usage:
28
 *
29
 * <?
30
 * require('oci_class.php');
31
 *
32
 * define(VIP_US,'user');
33
 * define(VIP_PW,'passwd');
34
 * define(VIP_DB,'dbname');
35
 *
36
 * $oci = new Oci(VIP_US, VIP_PW, VIP_DB);
37
 *
38
 * $oci->connect();
39
 *
40
 * $oci->set_query("SELECT * FROM sdi_user where EMAIL like '%dbc.dk'");
41
 *
42
 * echo '<PRE>';
43
 * while($data=$oci->fetch_into_assoc()) {
44
 *   print_r($data);
45
 * }
46
 * $oci->disconnect();
47
 *
48
 * ?>
49
 *
50
 * Example of how to use insert_BLOB
51
 *
52
 * Data is retrieved from xml with "minixml"
53
 *
54
 * Please notice that you should replace the name of the BLOB column with "EMPTY_BLBO()"
55
 * and instead give the name as the second parameter.
56
 *
57
 *for($cnt = 0; $cnt < $Pro->numChildren(); $cnt++ ) {
58
 *  $id = $AllProducts[$cnt]->getElement('Id')->getValue();
59
 *  echo "Id:$id\n";
60
 *
61
 *  // check whether the record is in the database;
62
 *  $idno = $oci->fetch_into_assoc("select id from xmldata where id = $id");
63
 *  if ( $oci->get_error() ) {
64
 *    print_web($oci->get_error(),"get_error: \n");
65
 *    exit;
66
 *  }
67
 *
68
 *  if ( $idno['ID'] == $id ) continue;
69
 *  $strng = $AllProducts[$cnt]->toString();
70
 *
71
 *  $oci->insert_BLOB("insert into xmldata ( id,createdate,data ) values( $id,sysdate,EMPTY_BLOB() )","data",$strng);
72
 *  if ( $oci->get_error() ) {
73
 *    print_web($oci->get_error(),"get_error: \n");
74
 *    exit;
75
 *  }
76
 *  $oci->commit();
77
 *  if ( $oci->get_error() ) {
78
 *    print_web($oci->get_error(),"get_error: \n");
79
 *    exit;
80
 *  }
81
 *}
82
 *
83
 */
118294 fvs 84
class ociException extends Exception {
82190 hhl 85
 
118294 fvs 86
  /** \brief constructor
87
   * @param $ociError array -
88
   */
82190 hhl 89
  public function __construct($ociError) {
90
    parent::__construct($ociError['message'] . ' --- ' . $ociError['sqltext']);
91
  }
92
 
118294 fvs 93
  /** \brief toString
94
   */
82190 hhl 95
  public function __toString() {
118294 fvs 96
    return 'ociException -->' . $this->getMessage() . ' --- ' . $this->getFile() . ':' . $this->getLine() . "\nStack trace:\n" . $this->getTraceAsString();
82190 hhl 97
  }
98
 
99
}
100
 
118294 fvs 101
/**
102
 * Class oci
103
 */
82190 hhl 104
class oci {
105
 
106
  ///////////////////////////////////////
107
  // PRIVATE VARIABLES DO NOT CHANGE!!!//
108
  ///////////////////////////////////////
109
 
110
  /// Value for successful connection - boolean
111
  var $connect;
112
 
113
  /// Oci statement - string
114
  var $statement;
115
 
116
  /// Bind list
117
  var $bind_list;
118
 
119
  /// SQL query - string
120
  var $query;
121
 
122
  /// Iterator for number of rows fetched. - integer
123
  var $num_fetched_rows;
124
 
125
  /// Username for database connection - string
126
  var $username;
127
 
128
  /// Password for database connection - string
129
  var $password;
130
 
131
  /// Tnsname for database connection - string
132
  var $database;
133
 
134
  /// Determines wether connection is persistent. - boolean
135
  var $persistent_connect = false;
136
 
137
  /// Contains error string. Empty if no error. - string
138
  var $error;
139
 
140
  /// Pagination enable flag - boolean
118294 fvs 141
  var $enable_pagination = false;
82190 hhl 142
 
143
  /// Pagination begin - integer
144
  var $begin;
145
 
146
  /// Pagination end - integer
147
  var $end;
148
 
149
  /// Default value for end - integer
118294 fvs 150
  var $end_default_val = 25;
82190 hhl 151
 
152
  /// Commit enabled - boolean
118294 fvs 153
  var $commit_enabled = false;
82190 hhl 154
 
155
  /// Set max connect retries
118294 fvs 156
  var $num_connect_attempts = 1;
82190 hhl 157
 
158
  /// Stores updated rows number - integer
159
  var $num_rows;
160
 
161
  ////////////////////
162
  // PUBLIC METHODS //
163
  ////////////////////
164
 
118294 fvs 165
  /** \brief  constructor
166
   * @param $username string - for db connection OR credentials in format: user/pwd\@dbname
167
   * @param $password string - for db connection
168
   * @param $database string - name (from tnsnames.ora)
169
   */
82190 hhl 170
 
118294 fvs 171
  function __construct($username, $password = '', $database = '') {
172
 
82190 hhl 173
    if ($password == '' && $database == '') {
174
      $this->username = '';
175
      $this->password = '';
176
      $this->database = '';
118294 fvs 177
      $expl = explode('/', $username, 2);
82190 hhl 178
      $this->username = $expl[0];
179
      if (isset($expl[1])) {
180
        $expl = explode('@', $expl[1]);
181
        $this->password = $expl[0];
182
        if (isset($expl[1]))
118294 fvs 183
          $this->database = $expl[1];
82190 hhl 184
      }
118294 fvs 185
    }
186
    else {
82190 hhl 187
      $this->username = $username;
188
      $this->password = $password;
189
      $this->database = $database;
190
    }
191
    if (defined('OCI_NUM_CONNECT_ATTEMTS')
118294 fvs 192
      && is_numeric(OCI_NUM_CONNECT_ATTEMTS)
193
      && OCI_NUM_CONNECT_ATTEMTS < 20
194
    )
82190 hhl 195
      $this->num_connect_attempts = OCI_NUM_CONNECT_ATTEMTS;
118294 fvs 196
 
82190 hhl 197
    $this->charset = NULL;
198
  }
118294 fvs 199
 
200
  /** \brief  destructor
201
   */
82190 hhl 202
  function destructor() {
203
    $this->disconnect();
204
  }
205
 
206
 
118294 fvs 207
  /** \brief -
208
   */
82190 hhl 209
  function cursor_open() {
210
    return oci_new_cursor($this->connect);
211
  }
212
 
118294 fvs 213
  /** \brief Set's pagination start and end values and enables pagination flag
214
   * @param $begin integer
215
   * @param $end integer
216
   */
82190 hhl 217
  function set_pagination($begin, $end) {
218
 
219
    if (empty($begin))
220
      $begin = 0;
221
 
222
    if (empty($end))
223
      $end = $this->end_default_val;
224
 
225
    if (!is_numeric($begin) || !is_numeric($end)) {
226
      Die('Validation error: Only integers allowed for pagination');
227
    }
228
 
229
    $this->begin = $begin;
230
    $this->end = $end;
231
 
232
    $this->enable_pagination = TRUE;
233
  }
234
 
235
 
118294 fvs 236
  /** \brief Sets number of attempts for connect
237
   * @param $num_connect_attempts integer
238
   * @return integer
239
   */
82190 hhl 240
  function set_num_connect_attempts($num_connect_attempts) {
241
    return $this->num_connect_attempts = $num_connect_attempts;
242
  }
243
 
118294 fvs 244
  /** \brief sets charset
245
   * @param $charset string
246
   * @return string
247
   */
82190 hhl 248
  function set_charset($charset) {
249
    return $this->charset = $charset;
250
  }
251
 
118294 fvs 252
  /** \brief Returns number of updated rows.
253
   * NB: This function does not return number of rows selected! For SELECT statements this function
254
   *     will return the number of rows, that were fetched to the buffer with oci_fetch*() functions.
255
   * @return integer
256
   */
82190 hhl 257
  function get_num_rows() {
258
    return $this->num_rows;
259
  }
260
 
261
 
118294 fvs 262
  /** \brief Check if connection is persistent
263
   * @return boolean
264
   */
82190 hhl 265
  function is_persistent_connect() {
266
    return $this->persistent_connect;
267
  }
268
 
118294 fvs 269
  /** \brief Get OCI error
270
   * @return string.
271
   */
82190 hhl 272
  function get_error() {
273
    return $this->error;
274
  }
275
 
118294 fvs 276
  /** \brief Return OCI error-string
277
   */
82190 hhl 278
  function get_error_string() {
279
    if ($this->error && is_array($this->error))
280
      return $this->error['code'] . ': ' . $this->error['message'];
281
    else
282
      return FALSE;
283
  }
284
 
285
 
118294 fvs 286
  /** \brief Get OCI connector
287
   *
288
   * Returns OCI connecter in case the user would like to work with it (i.e. for OCI functions not supported by this wrapper class).
289
   *
290
   * @return object.
291
   */
82190 hhl 292
  function get_connector() {
293
    return $this->connect;
294
  }
295
 
296
 
118294 fvs 297
  /** \brief Open new OCI connection
298
   * @param $connect_count integer
299
   * @return boolean.
300
   * @throws ociException
301
   */
302
  function connect($connect_count = -1) {
82190 hhl 303
 
304
    $this->clear_OCI_error();
305
 
306
    if (is_resource($this->connect)) {
98222 fvs 307
      // $this->oci_log(OCI, 'oci_pconnect:: ' . $this->username . '@' . $this->database . ' reuse connection');
82190 hhl 308
      return TRUE;
309
    }
310
 
311
    if ($connect_count == -1) $connect_count = $this->num_connect_attempts;
118294 fvs 312
 
313
    $this->connect = @oci_pconnect($this->username, $this->password, $this->database, $this->charset);
314
 
82190 hhl 315
    if (!is_resource($this->connect)) {
316
      if ($connect_count > 1) {
98222 fvs 317
        $this->oci_log(WARNING, 'oci_pconnect:: ' . $this->username . '@' . $this->database . ' reconnect (' . $connect_count . ') with error: ' . $this->get_error_string());
82190 hhl 318
        return $this->connect($connect_count - 1);
319
      }
320
 
321
      $this->set_OCI_error(oci_error());
98222 fvs 322
      $this->oci_log(ERROR, 'oci_pconnect:: ' . $this->username . '@' . $this->database . ' failed with error: ' . $this->get_error_string());
82190 hhl 323
      throw new ociException(oci_error());
118294 fvs 324
    }
82190 hhl 325
    else {
326
      return TRUE;
327
    }
328
  }
329
 
118294 fvs 330
  /** \brief Enable or disable commit
331
   * @param $state boolean
332
   */
82190 hhl 333
  function commit_enable($state) {
334
    $this->commit_enabled = $state;
335
  }
336
 
337
 
118294 fvs 338
  /** \brief Set and parse query
339
   * @param $query string - SQL query string
340
   * @return boolean
341
   * @throws ociException
342
   */
82190 hhl 343
  function set_query($query) {
118294 fvs 344
 
82190 hhl 345
    $this->clear_OCI_error();
346
    // reset num_fetched_rows iterator and result set
347
    $this->num_fetched_rows = 0;
348
    $this->result = array();
118294 fvs 349
 
82190 hhl 350
    // set query
118294 fvs 351
 
82190 hhl 352
    if ($this->enable_pagination) {
118294 fvs 353
 
82190 hhl 354
      $this->query = "SELECT *
355
                        FROM (SELECT /*+ FIRST_ROWS(10)) */ a.*, ROWNUM rnum
118294 fvs 356
                                FROM (" . $query . ") a
357
                               WHERE ROWNUM<=" . $this->end . " )
358
                       WHERE rnum>=" . $this->begin;
82190 hhl 359
 
118294 fvs 360
    }
361
    else {
82190 hhl 362
      $this->query = $query;
363
    }
118294 fvs 364
 
365
    $this->statement = @ociparse($this->connect, $this->query);
366
    if (!$this->statement) {
367
      if (is_resource($this->connect)) {
368
        $this->set_OCI_error(oci_error($this->connect));
369
      }
370
      else {
371
        $this->set_OCI_error('No OCI connection');
372
      }
373
      $this->oci_log(ERROR, 'ociparse:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
374
      throw new ociException($this->error);
82190 hhl 375
    }
118294 fvs 376
 
82190 hhl 377
    if (!empty($this->bind_list)) {
378
      foreach ($this->bind_list as $k => $v) {
118294 fvs 379
        $this->oci_log(OCI, 'ocibind:: ' . $v['name'] . ' bind to ' . $this->bind_list[$k]['value']);
380
        if (!@oci_bind_by_name($this->statement, $v['name'], $this->bind_list[$k]['value'], $v['maxlength'], $v['type'])) {
82190 hhl 381
          $this->set_OCI_error(oci_error($this->statement));
118294 fvs 382
          $this->oci_log(ERROR, 'oci_bind_by_name:: failed on ' . $this->query . ' binding ' . $v['name'] . ' to ' . $v['value'] . ' type: ' . $v['type'] . ' with error: ' . $this->get_error_string());
82190 hhl 383
          throw new ociException($this->error);
384
        }
385
      }
386
      $this->bind_list = array();
387
    }
118294 fvs 388
 
389
    if ($this->commit_enabled)
390
      $success = @ociexecute($this->statement, OCI_COMMIT_ON_SUCCESS);
82190 hhl 391
    else
118294 fvs 392
      $success = @ociexecute($this->statement, OCI_DEFAULT);
393
    if (!$success) {
82190 hhl 394
      $this->set_OCI_error(oci_error($this->statement));
98222 fvs 395
      $this->oci_log(ERROR, 'ociexecute:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
82190 hhl 396
      throw new ociException($this->error);
397
    }
398
    $this->num_rows = oci_num_rows($this->statement);
98222 fvs 399
    $this->oci_log(OCI, 'ociexecute:: ' . $this->query . ' success with no error: ' . $this->get_error_string());
82190 hhl 400
    return TRUE;
401
  }
402
 
403
 
118294 fvs 404
  /** \brief Insert data including a BLOB into a row in a database
405
   * @param $sql string - insert string in sql
406
   * @param $name string - is the name of the column name of the BLOB
407
   * @param $data string - a ref. to the data
408
   * @return integer
409
   * @throws ociException
410
   *
411
   * Ex. "insert into xmldata (id, createdate, xmldata) values ($id, sysdate, EMPTY_BLOB() )"
412
   */
82190 hhl 413
 
118294 fvs 414
  function insert_BLOB($sql, $name, &$data) {
82190 hhl 415
 
118294 fvs 416
    $this->query = $sql . " returning $name into :data_loc \n";
417
    $this->statement = @ociparse($this->connect, $this->query);
418
    $this->set_OCI_error(oci_error($this->connect));
419
    if (!is_resource($this->statement)) {
420
      $this->oci_log(ERROR, 'ociparse:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
421
      throw new ociException($this->error);
422
    }
82190 hhl 423
 
118294 fvs 424
    if (!empty($this->bind_list)) {
425
      foreach ($this->bind_list as $k => $v) {
426
        $success = @oci_bind_by_name($this->statement, $v['name'], $v['value'], $v['maxlength'], $v['type']);
82190 hhl 427
        $this->set_OCI_error(oci_error($this->statement));
118294 fvs 428
        if (!$success) {
429
          $this->oci_log(ERROR, 'oci_bind_by_name:: failed on ' . $this->query . ' binding ' . $v['name'] . ' to ' . $v['value'] . 'type: ' . $v['type'] . ' with error: ' . $this->get_error_string());
430
          throw new ociException($this->error);
431
        }
82190 hhl 432
      }
118294 fvs 433
      $this->bind_list = array();
434
    }
82190 hhl 435
 
118294 fvs 436
    // Creates an "empty" OCI-Lob object to bind to the locator
437
    if (!$dataLOB = @oci_new_descriptor($this->connect, OCI_D_LOB)) {
438
      $this->set_OCI_error(oci_error($this->statement));
439
      $this->oci_log(ERROR, 'oci_new_descriptor:: failed on  ' . $this->query . ' with error: ' . $this->get_error_string());
440
      throw new ociException($this->error);
441
    }
82190 hhl 442
 
118294 fvs 443
    // Bind the returned Oracle LOB locator to the PHP LOB object
444
    if (!@oci_bind_by_name($this->statement, ":data_loc", $dataLOB, strlen($data), OCI_B_BLOB)) {
445
      $this->set_OCI_error(oci_error($this->statement));
446
      $this->oci_log(ERROR, 'oci_bind_by_name:: failed on  ' . $this->query . ' with error: ' . $this->get_error_string());
447
      throw new ociException($this->error);
448
    }
82190 hhl 449
 
118294 fvs 450
    if (!@ociexecute($this->statement, OCI_DEFAULT)) {
451
      $this->set_OCI_error(oci_error($this->statement));
452
      $this->oci_log(ERROR, 'ociexecute:: failed on  ' . $this->query . ' with error: ' . $this->get_error_string());
453
      throw new ociException($this->error);
454
    }
82190 hhl 455
 
118294 fvs 456
    // Now import a file to the LOB
457
    if (!$dataLOB->save($data)) {
458
      $this->set_OCI_error(oci_error($this->statement));
459
      $this->oci_log(ERROR, 'save:: failed on  ' . $this->query . ' with error: ' . $this->get_error_string());
460
      throw new ociException($this->error);
82190 hhl 461
    }
462
 
118294 fvs 463
 
464
    // Free resources
465
    ociFreestatement($this->statement);
466
    $dataLOB->free();
467
 
468
    return TRUE;
469
  }
470
 
471
 
472
  /** \brief Commits outstanding statements
473
   * @return boolean
474
   * @throws ociException
475
   */
82190 hhl 476
  function commit() {
118294 fvs 477
    if (!oci_commit($this->connect)) {
82190 hhl 478
      $this->set_OCI_error(oci_error($this->statement));
98222 fvs 479
      $this->oci_log(ERROR, 'commit:: failed on  ' . $this->query . ' with error: ' . $this->get_error_string());
82190 hhl 480
      throw new ociException($this->error);
481
    }
482
 
118294 fvs 483
 
82190 hhl 484
  }
485
 
486
 
118294 fvs 487
  /** \brief Rollback outstanding statements
488
   * @return boolean
489
   * @throws ociException
490
   */
82190 hhl 491
  function rollback() {
118294 fvs 492
    if (!oci_rollback($this->connect)) {
82190 hhl 493
      $this->set_OCI_error(oci_error($this->statement));
98222 fvs 494
      $this->oci_log(ERROR, 'rollback:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
82190 hhl 495
      throw new ociException($this->error);
496
    }
497
    return TRUE;
498
  }
499
 
500
 
118294 fvs 501
  /** \brief Creates an empty OCI lob
502
   * @return OCI lob
503
   * @throws ociException
504
   */
82190 hhl 505
  function create_lob() {
506
    if ($lob = oci_new_descriptor($this->connect, OCI_D_LOB))
507
      return $lob;
508
    else {
509
      $this->set_OCI_error(oci_error($this->statement));
98222 fvs 510
      $this->oci_log(ERROR, 'create_lob:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
82190 hhl 511
      throw new ociException($this->error);
512
    }
513
  }
514
 
515
 
118294 fvs 516
  /** \brief Creates an empty OCI lob
517
   * @param $name string
518
   * @param $value mixed
519
   * @param $maxlength integer
520
   * @param $type integer|string
521
   */
522
  function bind($name, $value, $maxlength = -1, $type = SQLT_CHR) {
523
    $bind_array['name'] = ($name[0] == ':' ? $name : ':' . $name);
82190 hhl 524
    $bind_array['value'] = &$value;
525
    $bind_array['maxlength'] = $maxlength;
526
    $bind_array['type'] = $type;
527
    $this->bind_list[] = $bind_array;
528
  }
529
 
118294 fvs 530
  /** \brief Get query
531
   * @return string
532
   */
82190 hhl 533
  function get_query() {
534
    return $this->query;
535
  }
536
 
118294 fvs 537
  /** \brief Fetches current blob and return it. There must be only one element (the BLOB) to be fetched.
538
   * @param $sql string - SQL string
539
   * @return string | bool
540
   * @throws ociException
541
   */
82190 hhl 542
  function fetch_BLOB($sql = '') {
543
    if ($sql) {
544
      $this->set_query($sql);
545
      if ($this->error) return FALSE;
546
    }
547
 
118294 fvs 548
    if (!$res = oci_fetch_row($this->statement)) {
82190 hhl 549
      $this->set_OCI_error(oci_error($this->statement));
98222 fvs 550
      $this->oci_log(ERROR, 'fetch_BLOB:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
82190 hhl 551
      throw new ociException($this->error);
552
    }
118294 fvs 553
 
82190 hhl 554
    $this->num_fetched_rows++;
555
    $this->result = $res[0]->load();
556
 
557
    return $this->result;
558
  }
559
 
118294 fvs 560
  /** \brief Fetches current data into an associative array (use while loop around this function  to get all)
561
   * @param $sql string - SQL string
562
   * @return array | bool
563
   * @throws ociException
564
   */
82190 hhl 565
  function fetch_into_assoc($sql = '') {
566
    if ($sql) {
567
      $this->set_query($sql);
568
      if ($this->error) return FALSE;
569
    }
118294 fvs 570
    if (!$this->result = oci_fetch_array($this->statement, OCI_ASSOC + OCI_RETURN_NULLS)) {
82190 hhl 571
      $this->set_OCI_error(oci_error($this->statement));
572
      if ($this->error) {
98222 fvs 573
        $this->oci_log(ERROR, 'oci_fetch_array:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
82190 hhl 574
        throw new ociException($this->error);
575
      }
576
    }
577
    $this->num_fetched_rows++;
578
    return $this->result;
579
  }
580
 
581
 
118294 fvs 582
  /** \brief Fetches all data into an associative array
583
   * @param $sql string - SQL string
584
   * @return array | boolean
585
   * @throws ociException
586
   */
82190 hhl 587
  function fetch_all_into_assoc($sql = '') {
588
    if ($sql) {
589
      $this->set_query($sql);
590
      if ($this->error) return FALSE;
591
    }
592
 
118294 fvs 593
    while ($tmp_result = oci_fetch_array($this->statement, OCI_ASSOC + OCI_RETURN_NULLS)) {
82190 hhl 594
      $this->num_fetched_rows++;
595
      $this->result[] = $tmp_result;
596
    }
597
    $this->set_OCI_error(oci_error($this->statement));
598
    if ($this->error) {
98222 fvs 599
      $this->oci_log(ERROR, 'oci_fetch_all_into_assoc:: failed on ' . $this->query . ' with error: ' . $this->get_error_string());
82190 hhl 600
      throw new ociException(oci_error());
601
    }
602
    return $this->result;
603
  }
604
 
605
 
118294 fvs 606
  /** \brief Returns last number of rows fetched
607
   * @return integer
608
   */
82190 hhl 609
  function get_num_fetched_rows() {
610
    return $this->num_fetched_rows;
611
  }
612
 
613
 
118294 fvs 614
  /** \brief Closes OCI connection
615
   */
82190 hhl 616
  function disconnect() {
617
    ocilogoff($this->connect);
618
  }
619
 
620
  /////////////////////
621
  // PRIVATE METHODS //
622
  /////////////////////
623
 
118294 fvs 624
  /** \brief Set's OCI error
625
   * @param $OCIerror string - Expects output from oci_error() function (array)
626
   */
82190 hhl 627
  function set_OCI_error($OCIerror) {
628
    if ($OCIerror && empty($this->error))
629
      $this->error = $OCIerror;
630
  }
631
 
118294 fvs 632
  /** \brief Clear OCI error
633
   */
82190 hhl 634
  function clear_OCI_error() {
635
    $this->error = array();
636
  }
637
 
118294 fvs 638
  /** \brief Set's connection to persistent
639
   */
82190 hhl 640
  function set_persistent() {
118294 fvs 641
    $this->persistent_connect = true;
82190 hhl 642
  }
643
 
118294 fvs 644
  /**
645
   * @param $log_level integer
646
   * @param $msg string
647
   */
82190 hhl 648
  private function oci_log($log_level, $msg) {
120114 fvs 649
    if (method_exists('VerboseJson', 'log')) {
650
      VerboseJson::log($level, $msg);
651
    }
652
    elseif (method_exists('verbose', 'log')) {
653
      verbose::log($level, $msg);
654
    }
82190 hhl 655
  }
656
}