Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for Metafox/lib/DB/oci8.php between version 1.2 and 1.3

version 1.2, 2005/11/07 20:37:25 version 1.3, 2011/06/17 13:56:39
Line 18 
Line 18 
  * @package    DB   * @package    DB
  * @author     James L. Pine <jlp@valinux.com>   * @author     James L. Pine <jlp@valinux.com>
  * @author     Daniel Convissor <danielc@php.net>   * @author     Daniel Convissor <danielc@php.net>
  * @copyright  1997-2005 The PHP Group   * @copyright  1997-2007 The PHP Group
  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0   * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  * @version    CVS: $Id$   * @version    CVS: $Id$
  * @link       http://pear.php.net/package/DB   * @link       http://pear.php.net/package/DB
Line 45  require_once 'DB/common.php';
Line 45  require_once 'DB/common.php';
  * @package    DB   * @package    DB
  * @author     James L. Pine <jlp@valinux.com>   * @author     James L. Pine <jlp@valinux.com>
  * @author     Daniel Convissor <danielc@php.net>   * @author     Daniel Convissor <danielc@php.net>
  * @copyright  1997-2005 The PHP Group   * @copyright  1997-2007 The PHP Group
  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0   * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  * @version    Release: 1.7.6   * @version    Release: 1.7.14RC2
  * @link       http://pear.php.net/package/DB   * @link       http://pear.php.net/package/DB
  */   */
 class DB_oci8 extends DB_common  class DB_oci8 extends DB_common
Line 94  class DB_oci8 extends DB_common
Line 94  class DB_oci8 extends DB_common
      * @var array       * @var array
      */       */
     var $errorcode_map = array(      var $errorcode_map = array(
         1    => DB_ERROR_CONSTRAINT,          1     => DB_ERROR_CONSTRAINT,
         900  => DB_ERROR_SYNTAX,          900   => DB_ERROR_SYNTAX,
         904  => DB_ERROR_NOSUCHFIELD,          904   => DB_ERROR_NOSUCHFIELD,
         913  => DB_ERROR_VALUE_COUNT_ON_ROW,          913   => DB_ERROR_VALUE_COUNT_ON_ROW,
         921  => DB_ERROR_SYNTAX,          921   => DB_ERROR_SYNTAX,
         923  => DB_ERROR_SYNTAX,          923   => DB_ERROR_SYNTAX,
         942  => DB_ERROR_NOSUCHTABLE,          942   => DB_ERROR_NOSUCHTABLE,
         955  => DB_ERROR_ALREADY_EXISTS,          955   => DB_ERROR_ALREADY_EXISTS,
         1400 => DB_ERROR_CONSTRAINT_NOT_NULL,          1400  => DB_ERROR_CONSTRAINT_NOT_NULL,
         1401 => DB_ERROR_INVALID,          1401  => DB_ERROR_INVALID,
         1407 => DB_ERROR_CONSTRAINT_NOT_NULL,          1407  => DB_ERROR_CONSTRAINT_NOT_NULL,
         1418 => DB_ERROR_NOT_FOUND,          1418  => DB_ERROR_NOT_FOUND,
         1476 => DB_ERROR_DIVZERO,          1476  => DB_ERROR_DIVZERO,
         1722 => DB_ERROR_INVALID_NUMBER,          1722  => DB_ERROR_INVALID_NUMBER,
         2289 => DB_ERROR_NOSUCHTABLE,          2289  => DB_ERROR_NOSUCHTABLE,
         2291 => DB_ERROR_CONSTRAINT,          2291  => DB_ERROR_CONSTRAINT,
         2292 => DB_ERROR_CONSTRAINT,          2292  => DB_ERROR_CONSTRAINT,
         2449 => DB_ERROR_CONSTRAINT,          2449  => DB_ERROR_CONSTRAINT,
           12899 => DB_ERROR_INVALID,
     );      );
   
     /**      /**
Line 160  class DB_oci8 extends DB_common
Line 161  class DB_oci8 extends DB_common
      */       */
     var $manip_query = array();      var $manip_query = array();
   
       /**
        * Store of prepared SQL queries.
        * @var array
        * @access private
        */
       var $_prepared_queries = array();
   
   
     // }}}      // }}}
     // {{{ constructor      // {{{ constructor
Line 216  class DB_oci8 extends DB_common
Line 224  class DB_oci8 extends DB_common
             $this->dbsyntax = $dsn['dbsyntax'];              $this->dbsyntax = $dsn['dbsyntax'];
         }          }
   
           // Backwards compatibility with DB < 1.7.0
           if (empty($dsn['database']) && !empty($dsn['hostspec'])) {
               $db = $dsn['hostspec'];
           } else {
               $db = $dsn['database'];
           }
   
         if (function_exists('oci_connect')) {          if (function_exists('oci_connect')) {
             if (isset($dsn['new_link'])              if (isset($dsn['new_link'])
                 && ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))                  && ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
Line 225  class DB_oci8 extends DB_common
Line 240  class DB_oci8 extends DB_common
                 $connect_function = $persistent ? 'oci_pconnect'                  $connect_function = $persistent ? 'oci_pconnect'
                                     : 'oci_connect';                                      : 'oci_connect';
             }              }
               if (isset($this->dsn['port']) && $this->dsn['port']) {
             // Backwards compatibility with DB < 1.7.0                  $db = '//'.$db.':'.$this->dsn['port'];
             if (empty($dsn['database']) && !empty($dsn['hostspec'])) {  
                 $db = $dsn['hostspec'];  
             } else {  
                 $db = $dsn['database'];  
             }              }
   
             $char = empty($dsn['charset']) ? null : $dsn['charset'];              $char = empty($dsn['charset']) ? null : $dsn['charset'];
Line 248  class DB_oci8 extends DB_common
Line 259  class DB_oci8 extends DB_common
             }              }
         } else {          } else {
             $connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';              $connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';
             if ($dsn['hostspec']) {              if ($db) {
                 $this->connection = @$connect_function($dsn['username'],                  $this->connection = @$connect_function($dsn['username'],
                                                        $dsn['password'],                                                         $dsn['password'],
                                                        $dsn['hostspec']);                                                         $db);
             } elseif ($dsn['username'] || $dsn['password']) {              } elseif ($dsn['username'] || $dsn['password']) {
                 $this->connection = @$connect_function($dsn['username'],                  $this->connection = @$connect_function($dsn['username'],
                                                        $dsn['password']);                                                         $dsn['password']);
Line 322  class DB_oci8 extends DB_common
Line 333  class DB_oci8 extends DB_common
             return $this->oci8RaiseError($result);              return $this->oci8RaiseError($result);
         }          }
         $this->last_stmt = $result;          $this->last_stmt = $result;
         if (DB::isManip($query)) {          if ($this->_checkManip($query)) {
             return DB_OK;              return DB_OK;
         } else {          } else {
             @ocisetprefetch($result, $this->options['result_buffering']);              @ocisetprefetch($result, $this->options['result_buffering']);
Line 415  class DB_oci8 extends DB_common
Line 426  class DB_oci8 extends DB_common
      */       */
     function freeResult($result)      function freeResult($result)
     {      {
         return @OCIFreeStatement($result);          return is_resource($result) ? OCIFreeStatement($result) : false;
     }      }
   
     /**      /**
Line 441  class DB_oci8 extends DB_common
Line 452  class DB_oci8 extends DB_common
         if (isset($this->prepare_types[(int)$stmt])) {          if (isset($this->prepare_types[(int)$stmt])) {
             unset($this->prepare_types[(int)$stmt]);              unset($this->prepare_types[(int)$stmt]);
             unset($this->manip_query[(int)$stmt]);              unset($this->manip_query[(int)$stmt]);
               unset($this->_prepared_queries[(int)$stmt]);
         } else {          } else {
             return false;              return false;
         }          }
Line 476  class DB_oci8 extends DB_common
Line 488  class DB_oci8 extends DB_common
             $save_query = $this->last_query;              $save_query = $this->last_query;
             $save_stmt = $this->last_stmt;              $save_stmt = $this->last_stmt;
   
             if (count($this->_data)) {              $count = $this->query($countquery);
                 $smt = $this->prepare('SELECT COUNT(*) FROM ('.$this->last_query.')');  
                 $count = $this->execute($smt, $this->_data);  
             } else {  
                 $count =& $this->query($countquery);  
             }  
   
               // Restore the last query and statement.
               $this->last_query = $save_query;
               $this->last_stmt = $save_stmt;
   
             if (DB::isError($count) ||              if (DB::isError($count) ||
                 DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED)))                  DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED)))
             {              {
                 $this->last_query = $save_query;  
                 $this->last_stmt = $save_stmt;  
                 return $this->raiseError(DB_ERROR_NOT_CAPABLE);                  return $this->raiseError(DB_ERROR_NOT_CAPABLE);
             }              }
   
             return $row[0];              return $row[0];
         }          }
         return $this->raiseError(DB_ERROR_NOT_CAPABLE);          return $this->raiseError(DB_ERROR_NOT_CAPABLE);
Line 590  class DB_oci8 extends DB_common
Line 600  class DB_oci8 extends DB_common
         }          }
         $this->prepare_types[(int)$stmt] = $types;          $this->prepare_types[(int)$stmt] = $types;
         $this->manip_query[(int)$stmt] = DB::isManip($query);          $this->manip_query[(int)$stmt] = DB::isManip($query);
           $this->_prepared_queries[(int)$stmt] = $newquery;
         return $stmt;          return $stmt;
     }      }
   
Line 620  class DB_oci8 extends DB_common
Line 631  class DB_oci8 extends DB_common
     {      {
         $data = (array)$data;          $data = (array)$data;
         $this->last_parameters = $data;          $this->last_parameters = $data;
           $this->last_query = $this->_prepared_queries[(int)$stmt];
         $this->_data = $data;          $this->_data = $data;
   
         $types =& $this->prepare_types[(int)$stmt];          $types = $this->prepare_types[(int)$stmt];
         if (count($types) != count($data)) {          if (count($types) != count($data)) {
             $tmp =& $this->raiseError(DB_ERROR_MISMATCH);              $tmp = $this->raiseError(DB_ERROR_MISMATCH);
             return $tmp;              return $tmp;
         }          }
   
Line 643  class DB_oci8 extends DB_common
Line 655  class DB_oci8 extends DB_common
             } elseif ($types[$i] == DB_PARAM_OPAQUE) {              } elseif ($types[$i] == DB_PARAM_OPAQUE) {
                 $fp = @fopen($data[$key], 'rb');                  $fp = @fopen($data[$key], 'rb');
                 if (!$fp) {                  if (!$fp) {
                     $tmp =& $this->raiseError(DB_ERROR_ACCESS_VIOLATION);                      $tmp = $this->raiseError(DB_ERROR_ACCESS_VIOLATION);
                     return $tmp;                      return $tmp;
                 }                  }
                 $data[$key] = fread($fp, filesize($data[$key]));                  $data[$key] = fread($fp, filesize($data[$key]));
                 fclose($fp);                  fclose($fp);
               } elseif ($types[$i] == DB_PARAM_SCALAR) {
                   // Floats have to be converted to a locale-neutral
                   // representation.
                   if (is_float($data[$key])) {
                       $data[$key] = $this->quoteFloat($data[$key]);
                   }
             }              }
             if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {              if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {
                 $tmp = $this->oci8RaiseError($stmt);                  $tmp = $this->oci8RaiseError($stmt);
                 return $tmp;                  return $tmp;
             }              }
               $this->last_query = preg_replace("/:bind$i(?!\d)/",
                       $this->quoteSmart($data[$key]), $this->last_query, 1);
             $i++;              $i++;
         }          }
         if ($this->autocommit) {          if ($this->autocommit) {
Line 665  class DB_oci8 extends DB_common
Line 685  class DB_oci8 extends DB_common
             return $tmp;              return $tmp;
         }          }
         $this->last_stmt = $stmt;          $this->last_stmt = $stmt;
         if ($this->manip_query[(int)$stmt]) {          if ($this->manip_query[(int)$stmt] || $this->_next_query_manip) {
               $this->_last_query_manip = true;
               $this->_next_query_manip = false;
             $tmp = DB_OK;              $tmp = DB_OK;
         } else {          } else {
               $this->_last_query_manip = false;
             @ocisetprefetch($stmt, $this->options['result_buffering']);              @ocisetprefetch($stmt, $this->options['result_buffering']);
             $tmp =& new DB_result($this, $stmt);              $tmp = new DB_result($this, $stmt);
         }          }
         return $tmp;          return $tmp;
     }      }
Line 797  class DB_oci8 extends DB_common
Line 820  class DB_oci8 extends DB_common
         if (count($params)) {          if (count($params)) {
             $result = $this->prepare("SELECT * FROM ($query) "              $result = $this->prepare("SELECT * FROM ($query) "
                                      . 'WHERE NULL = NULL');                                       . 'WHERE NULL = NULL');
             $tmp =& $this->execute($result, $params);              $tmp = $this->execute($result, $params);
         } else {          } else {
             $q_fields = "SELECT * FROM ($query) WHERE NULL = NULL";              $q_fields = "SELECT * FROM ($query) WHERE NULL = NULL";
   
Line 857  class DB_oci8 extends DB_common
Line 880  class DB_oci8 extends DB_common
         $repeat = 0;          $repeat = 0;
         do {          do {
             $this->expectError(DB_ERROR_NOSUCHTABLE);              $this->expectError(DB_ERROR_NOSUCHTABLE);
             $result =& $this->query("SELECT ${seqname}.nextval FROM dual");              $result = $this->query("SELECT ${seqname}.nextval FROM dual");
             $this->popExpect();              $this->popExpect();
             if ($ondemand && DB::isError($result) &&              if ($ondemand && DB::isError($result) &&
                 $result->getCode() == DB_ERROR_NOSUCHTABLE) {                  $result->getCode() == DB_ERROR_NOSUCHTABLE) {
Line 1015  class DB_oci8 extends DB_common
Line 1038  class DB_oci8 extends DB_common
             if (!@OCIExecute($stmt, OCI_DEFAULT)) {              if (!@OCIExecute($stmt, OCI_DEFAULT)) {
                 return $this->oci8RaiseError($stmt);                  return $this->oci8RaiseError($stmt);
             }              }
   
             $i = 0;              $i = 0;
             while (@OCIFetch($stmt)) {              while (@OCIFetch($stmt)) {
                 $res[$i] = array(                  $res[$i] = array(
Line 1098  class DB_oci8 extends DB_common
Line 1121  class DB_oci8 extends DB_common
                 return 'SELECT table_name FROM user_tables';                  return 'SELECT table_name FROM user_tables';
             case 'synonyms':              case 'synonyms':
                 return 'SELECT synonym_name FROM user_synonyms';                  return 'SELECT synonym_name FROM user_synonyms';
               case 'views':
                   return 'SELECT view_name FROM user_views';
             default:              default:
                 return null;                  return null;
         }          }
     }      }
   
     // }}}      // }}}
       // {{{ quoteFloat()
   
       /**
        * Formats a float value for use within a query in a locale-independent
        * manner.
        *
        * @param float the float value to be quoted.
        * @return string the quoted string.
        * @see DB_common::quoteSmart()
        * @since Method available since release 1.7.8.
        */
       function quoteFloat($float) {
           return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
       }
   
       // }}}
   
 }  }
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top