[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-cvs
Subject:    [PEAR-CVS] cvs: pear /MDB/MDB Common.php
From:       "Lukas Smith" <lsmith () php ! net>
Date:       2003-07-31 12:12:36
[Download RAW message or body]

lsmith		Thu Jul 31 08:12:36 2003 EDT

  Modified files:              
    /pear/MDB/MDB	Common.php 
  Log:
  minor cleanups in regards to options and debug handling
  
["lsmith-20030731081236.txt" (text/plain)]

Index: pear/MDB/MDB/Common.php
diff -u pear/MDB/MDB/Common.php:1.117 pear/MDB/MDB/Common.php:1.118
--- pear/MDB/MDB/Common.php:1.117	Thu Jul 31 06:31:03 2003
+++ pear/MDB/MDB/Common.php	Thu Jul 31 08:12:36 2003
@@ -42,7 +42,7 @@
 // | Author: Lukas Smith <smith@backendmedia.com>                         |
 // +----------------------------------------------------------------------+
 //
-// $Id: Common.php,v 1.117 2003/07/31 10:31:03 lsmith Exp $
+// $Id: Common.php,v 1.118 2003/07/31 12:12:36 lsmith Exp $
 
 /**
  * @package MDB
@@ -66,7 +66,7 @@
  */
 function MDB_defaultDebugOutput(&$db, $message)
 {
-    $db->debug_output .= $db->database . " $message" . $db->getOption('log_line_break');
+    $db->debug_output .= $db->database.': '.$message.$db->getOption('log_line_break');
 }
 
 /**
@@ -80,64 +80,74 @@
 {
     // {{{ properties
     /**
-    * index of the MDB object withing the global $_MDB_databases array
-    * @var integer
-    * @access private
-    */
+     * index of the MDB object withing the global $_MDB_databases array
+     * @var integer
+     * @access private
+     */
     var $database = 0;
 
     /**
-    * @var string
-    * @access private
-    */
+     * assoc mapping native error codes to DB ones
+     * @var array
+     */
+    var $errorcode_map = array();
+
+    /**
+     * @var string
+     * @access private
+     */
     var $host = '';
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $port = '';
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $user = '';
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $password = '';
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $database_name = '';
 
     /**
-    * @var array
-    * @access private
-    */
+     * @var array
+     * @access private
+     */
     var $supported = array();
 
     /**
-    * $options["persistent"] -> boolean persistent connection true|false?
-    * $options["debug"] -> integer numeric debug level
-    * $options["autofree"] -> boolean
-    * $options["lob_buffer_length"] -> integer LOB buffer length
-    * $options["log_line_break"] -> string line-break format
-    * $options["seqname_format"] -> string pattern for sequence name
-    * $options["includelob"] -> boolean
-    * $options["includemanager"] -> boolean
-    * $options["UseTransactions"] -> boolean
-    * @var array
-    * @access private
-    */
+     * $options["optimize"] -> string 'performance' or 'portability'
+     * $options['persistent'] -> boolean persistent connection?
+     * $options['debug'] -> integer numeric debug level
+     * $options['debug_handler'] -> string function/meothd that captures debug messages
+     * $options['autofree'] -> boolean automatically free result that have been read to the end?
+     * $options['lob_buffer_length'] -> integer LOB buffer length
+     * $options['log_line_break'] -> string line-break format
+     * $options['seqname_format'] -> string pattern for sequence name
+     * $options['include_lob'] -> boolean
+     * $options['include_manager'] -> boolean
+     * $options['use_transactions'] -> boolean
+     * @var array
+     * @access private
+     */
     var $options = array(
+            'optimize' => 'portability',
             'persistent' => false,
-            'debug' => false,
+            'debug' => 0,
+            'debug_handler' => 'MDB_defaultDebugOutput',
             'autofree' => false,
             'lob_buffer_length' => 8192,
             'log_line_break' => "\n",
@@ -148,118 +158,101 @@
         );
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $escape_quotes = '';
 
     /**
-    * @var integer
-    * @access private
-    */
+     * @var integer
+     * @access private
+     */
     var $decimal_places = 2;
 
     /**
-    * @var string
-    * @access private
-    */
-    var $manager_included_constant = '';
-
-    /**
-    * @var string
-    * @access private
-    */
-    var $manager_include = '';
-
-    /**
-    * @var string
-    * @access private
-    */
-    var $manager_class_name = '';
-
-    /**
-    * @var object
-    * @access private
-    */
+     * @var object
+     * @access private
+     */
     var $manager;
 
     /**
-    * @var array
-    * @access private
-    */
+     * @var array
+     * @access private
+     */
     var $warnings = array();
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $debug = '';
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $debug_output = '';
 
     /**
-    * @var boolean
-    * @access private
-    */
-    var $pass_debug_handle = false;
-
-    /**
-    * @var boolean
-    * @access private
-    */
+     * @var boolean
+     * @access private
+     */
     var $auto_commit = 1;
 
     /**
-    * @var boolean
-    * @access private
-    */
+     * @var boolean
+     * @access private
+     */
     var $in_transaction = 0;
 
     /**
-    * @var integer
-    * @access private
-    */
+     * @var integer
+     * @access private
+     */
     var $first_selected_row = 0;
 
     /**
-    * @var integer
-    * @access private
-    */
+     * @var integer
+     * @access private
+     */
     var $selected_row_limit = 0;
 
     /**
-    * DB type (mysql, oci8, odbc etc.)
-    * @var string
-    * @access private
-    */
-    var $type;
+     * Database backend used in PHP (mysql, odbc etc.)
+     * @var string
+     * @access private
+     */
+    var $phptype;
 
     /**
-    * @var array
-    * @access private
-    */
+     * Database used with regards to SQL syntax etc.
+     * @var string
+     * @access private
+     */
+    var $dbsyntax;
+
+    /**
+     * @var array
+     * @access private
+     */
     var $prepared_queries = array();
 
     /**
-    * @var string
-    * @access private
-    */
+     * @var string
+     * @access private
+     */
     var $last_query = '';
 
     /**
-    * @var integer
-    * @access private
-    */
+     * @var integer
+     * @access private
+     */
     var $fetchmode = MDB_FETCHMODE_ORDERED;
 
     /**
-    * @var integer
-    * @access private
-    */
+     * @var integer
+     * @access private
+     */
     var $affected_rows = -1;
 
     // }}}
@@ -276,9 +269,6 @@
         $this->database = $database;
 
         $this->PEAR('MDB_Error');
-        $this->supported = array();
-        $this->errorcode_map = array();
-        $this->fetchmode = MDB_FETCHMODE_ORDERED;
     }
 
     // }}}
@@ -288,9 +278,9 @@
      * String conversation
      *
      * @return string
-     * @access private
+     * @access public
      */
-    function _toString()
+    function toString()
     {
         $info = get_class($this);
         $info .= ': (phptype = ' . $this->phptype . ', dbsyntax = ' . $this->dbsyntax . ')';
@@ -466,23 +456,6 @@
     }
 
     // }}}
-    // {{{ captureDebugOutput()
-
-    /**
-     * set a debug handler
-     *
-     * @param string $capture name of the function that should be used in
-     *      debug()
-     * @access public
-     * @see debug()
-     */
-    function captureDebugOutput($capture)
-    {
-        $this->pass_debug_handle = $capture;
-        $this->debug = ($capture ? 'MDB_defaultDebugOutput' : '');
-    }
-
-    // }}}
     // {{{ debug()
 
     /**
@@ -493,12 +466,8 @@
      */
     function debug($message)
     {
-        if (strcmp($function = $this->debug, '')) {
-            if ($this->pass_debug_handle) {
-                $function($this, $message);
-            } else {
-                $function($message);
-            }
+        if ($this->debug && $this->option['debug_handler']) {
+        	call_user_func($this->option['debug_handler'], $this, $message);
         }
     }
 
@@ -589,7 +558,7 @@
         if (MDB::isError($result)) {
             return $result;
         }
-        $class_name = 'MDB_Manager_'.$this->dbsyntax;
+        $class_name = 'MDB_Manager_'.$this->phptype;
         if (!class_exists($class_name)) {
             return $this->raiseError(MDB_ERROR_LOADMODULE, null, null,
                 'Unable to load extension');
@@ -619,7 +588,7 @@
         if (MDB::isError($result)) {
             return $result;
         }
-        $class_name = 'MDB_Datatype_'.$this->dbsyntax;
+        $class_name = 'MDB_Datatype_'.$this->phptype;
         if (!class_exists($class_name)) {
             return $this->raiseError(MDB_ERROR_LOADMODULE, null, null,
                 'Unable to load extension');



-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic