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.php between version 1.2 and 1.3

version 1.2, 2005/11/07 20:37:10 version 1.3, 2011/06/17 13:56:38
Line 18 
Line 18 
  * @author     Stig Bakken <ssb@php.net>   * @author     Stig Bakken <ssb@php.net>
  * @author     Tomas V.V.Cox <cox@idecnet.com>   * @author     Tomas V.V.Cox <cox@idecnet.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 424  define('DB_PORTABILITY_ALL', 63);
Line 424  define('DB_PORTABILITY_ALL', 63);
  * @author     Stig Bakken <ssb@php.net>   * @author     Stig Bakken <ssb@php.net>
  * @author     Tomas V.V.Cox <cox@idecnet.com>   * @author     Tomas V.V.Cox <cox@idecnet.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  class DB
Line 467  class DB
Line 467  class DB
             return $tmp;              return $tmp;
         }          }
   
         @$obj =& new $classname;          @$obj = new $classname;
   
         foreach ($options as $option => $value) {          foreach ($options as $option => $value) {
             $test = $obj->setOption($option, $value);              $test = $obj->setOption($option, $value);
Line 544  class DB
Line 544  class DB
             return $tmp;              return $tmp;
         }          }
   
         @$obj =& new $classname;          @$obj = new $classname;
   
         foreach ($options as $option => $value) {          foreach ($options as $option => $value) {
             $test = $obj->setOption($option, $value);              $test = $obj->setOption($option, $value);
Line 555  class DB
Line 555  class DB
   
         $err = $obj->connect($dsninfo, $obj->getOption('persistent'));          $err = $obj->connect($dsninfo, $obj->getOption('persistent'));
         if (DB::isError($err)) {          if (DB::isError($err)) {
             $err->addUserInfo($dsn);              if (is_array($dsn)) {
                   $err->addUserInfo(DB::getDSNString($dsn, true));
               } else {
                   $err->addUserInfo($dsn);
               }
             return $err;              return $err;
         }          }
   
Line 572  class DB
Line 576  class DB
      */       */
     function apiVersion()      function apiVersion()
     {      {
         return '1.7.6';          return '1.7.14RC2';
     }      }
   
     // }}}      // }}}
Line 625  class DB
Line 629  class DB
     {      {
         $manips = 'INSERT|UPDATE|DELETE|REPLACE|'          $manips = 'INSERT|UPDATE|DELETE|REPLACE|'
                 . 'CREATE|DROP|'                  . 'CREATE|DROP|'
                 . 'LOAD DATA|SELECT .* INTO|COPY|'                  . 'LOAD DATA|SELECT .* INTO .* FROM|COPY|'
                 . 'ALTER|GRANT|REVOKE|'                  . 'ALTER|GRANT|REVOKE|'
                 . 'LOCK|UNLOCK';                  . 'LOCK|UNLOCK';
         if (preg_match('/^\s*"?(' . $manips . ')\s+/i', $query)) {          if (preg_match('/^\s*"?(' . $manips . ')\s+/i', $query)) {
Line 808  class DB
Line 812  class DB
         // process the different protocol options          // process the different protocol options
         $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp';          $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp';
         $proto_opts = rawurldecode($proto_opts);          $proto_opts = rawurldecode($proto_opts);
           if (strpos($proto_opts, ':') !== false) {
               list($proto_opts, $parsed['port']) = explode(':', $proto_opts);
           }
         if ($parsed['protocol'] == 'tcp') {          if ($parsed['protocol'] == 'tcp') {
             if (strpos($proto_opts, ':') !== false) {              $parsed['hostspec'] = $proto_opts;
                 list($parsed['hostspec'],  
                      $parsed['port']) = explode(':', $proto_opts);  
             } else {  
                 $parsed['hostspec'] = $proto_opts;  
             }  
         } elseif ($parsed['protocol'] == 'unix') {          } elseif ($parsed['protocol'] == 'unix') {
             $parsed['socket'] = $proto_opts;              $parsed['socket'] = $proto_opts;
         }          }
Line 848  class DB
Line 850  class DB
     }      }
   
     // }}}      // }}}
       // {{{ getDSNString()
   
       /**
        * Returns the given DSN in a string format suitable for output.
        *
        * @param array|string the DSN to parse and format
        * @param boolean true to hide the password, false to include it
        * @return string
        */
       function getDSNString($dsn, $hidePassword) {
           /* Calling parseDSN will ensure that we have all the array elements
            * defined, and means that we deal with strings and array in the same
            * manner. */
           $dsnArray = DB::parseDSN($dsn);
   
           if ($hidePassword) {
               $dsnArray['password'] = 'PASSWORD';
           }
   
           /* Protocol is special-cased, as using the default "tcp" along with an
            * Oracle TNS connection string fails. */
           if (is_string($dsn) && strpos($dsn, 'tcp') === false && $dsnArray['protocol'] == 'tcp') {
               $dsnArray['protocol'] = false;
           }
   
           // Now we just have to construct the actual string. This is ugly.
           $dsnString = $dsnArray['phptype'];
           if ($dsnArray['dbsyntax']) {
               $dsnString .= '('.$dsnArray['dbsyntax'].')';
           }
           $dsnString .= '://'
                        .$dsnArray['username']
                        .':'
                        .$dsnArray['password']
                        .'@'
                        .$dsnArray['protocol'];
           if ($dsnArray['socket']) {
               $dsnString .= '('.$dsnArray['socket'].')';
           }
           if ($dsnArray['protocol'] && $dsnArray['hostspec']) {
               $dsnString .= '+';
           }
           $dsnString .= $dsnArray['hostspec'];
           if ($dsnArray['port']) {
               $dsnString .= ':'.$dsnArray['port'];
           }
           $dsnString .= '/'.$dsnArray['database'];
   
           /* Option handling. Unfortunately, parseDSN simply places options into
            * the top-level array, so we'll first get rid of the fields defined by
            * DB and see what's left. */
           unset($dsnArray['phptype'],
                 $dsnArray['dbsyntax'],
                 $dsnArray['username'],
                 $dsnArray['password'],
                 $dsnArray['protocol'],
                 $dsnArray['socket'],
                 $dsnArray['hostspec'],
                 $dsnArray['port'],
                 $dsnArray['database']
           );
           if (count($dsnArray) > 0) {
               $dsnString .= '?';
               $i = 0;
               foreach ($dsnArray as $key => $value) {
                   if (++$i > 1) {
                       $dsnString .= '&';
                   }
                   $dsnString .= $key.'='.$value;
               }
           }
   
           return $dsnString;
       }
   
       // }}}
 }  }
   
 // }}}  // }}}
Line 860  class DB
Line 938  class DB
  * @category   Database   * @category   Database
  * @package    DB   * @package    DB
  * @author     Stig Bakken <ssb@php.net>   * @author     Stig Bakken <ssb@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_Error extends PEAR_Error  class DB_Error extends PEAR_Error
Line 907  class DB_Error extends PEAR_Error
Line 985  class DB_Error extends PEAR_Error
  * @category   Database   * @category   Database
  * @package    DB   * @package    DB
  * @author     Stig Bakken <ssb@php.net>   * @author     Stig Bakken <ssb@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_result  class DB_result
Line 1089  class DB_result
Line 1167  class DB_result
             $fetchmode = DB_FETCHMODE_ASSOC;              $fetchmode = DB_FETCHMODE_ASSOC;
             $object_class = $this->fetchmode_object_class;              $object_class = $this->fetchmode_object_class;
         }          }
         if ($this->limit_from !== null) {          if (is_null($rownum) && $this->limit_from !== null) {
             if ($this->row_counter === null) {              if ($this->row_counter === null) {
                 $this->row_counter = $this->limit_from;                  $this->row_counter = $this->limit_from;
                 // Skip rows                  // Skip rows
Line 1121  class DB_result
Line 1199  class DB_result
                 if ($object_class == 'stdClass') {                  if ($object_class == 'stdClass') {
                     $arr = (object) $arr;                      $arr = (object) $arr;
                 } else {                  } else {
                     $arr = &new $object_class($arr);                      $arr = new $object_class($arr);
                 }                  }
             }              }
             return $arr;              return $arr;
Line 1171  class DB_result
Line 1249  class DB_result
             $fetchmode = DB_FETCHMODE_ASSOC;              $fetchmode = DB_FETCHMODE_ASSOC;
             $object_class = $this->fetchmode_object_class;              $object_class = $this->fetchmode_object_class;
         }          }
         if ($this->limit_from !== null) {          if (is_null($rownum) && $this->limit_from !== null) {
             if ($this->row_counter === null) {              if ($this->row_counter === null) {
                 $this->row_counter = $this->limit_from;                  $this->row_counter = $this->limit_from;
                 // Skip rows                  // Skip rows
Line 1253  class DB_result
Line 1331  class DB_result
             while ($res->fetchInto($tmp, DB_FETCHMODE_ORDERED)) {              while ($res->fetchInto($tmp, DB_FETCHMODE_ORDERED)) {
                 $i++;                  $i++;
             }              }
             return $i;              $count = $i;
         } else {          } else {
             return $this->dbh->numRows($this->result);              $count = $this->dbh->numRows($this->result);
         }          }
   
           /* fbsql is checked for here because limit queries are implemented
            * using a TOP() function, which results in fbsql_num_rows still
            * returning the total number of rows that would have been returned,
            * rather than the real number. As a result, we'll just do the limit
            * calculations for fbsql in the same way as a database with emulated
            * limits. Unfortunately, we can't just do this in DB_fbsql::numRows()
            * because that only gets the result resource, rather than the full
            * DB_Result object. */
           if (($this->dbh->features['limit'] === 'emulate'
                && $this->limit_from !== null)
               || $this->dbh->phptype == 'fbsql') {
               $limit_count = is_null($this->limit_count) ? $count : $this->limit_count;
               if ($count < $this->limit_from) {
                   $count = 0;
               } elseif ($count < ($this->limit_from + $limit_count)) {
                   $count -= $this->limit_from;
               } else {
                   $count = $limit_count;
               }
           }
   
           return $count;
     }      }
   
     // }}}      // }}}
Line 1349  class DB_result
Line 1450  class DB_result
  * @category   Database   * @category   Database
  * @package    DB   * @package    DB
  * @author     Stig Bakken <ssb@php.net>   * @author     Stig Bakken <ssb@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
  * @see        DB_common::setFetchMode()   * @see        DB_common::setFetchMode()
  */   */

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