We can now get DB errors without notices or warnings
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 20 Dec 2006 01:13:22 +0000 (01:13 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 20 Dec 2006 01:13:22 +0000 (01:13 +0000)
Db.php
DbMySql.php
DbMySqlI.php
DbPostgreSql.php

diff --git a/Db.php b/Db.php
index 246f0ca17a0b3cb4a92ffd80f56ff166fe347b39..d8d1d144e76d47cfc5bb3e6bd1d21120b8d961a6 100644 (file)
--- a/Db.php
+++ b/Db.php
@@ -421,6 +421,17 @@ abstract class BSDb
        */
        protected abstract function _affectedRows($result);
        
+       // ###################################################################
+       /**
+       * Returns the errror number
+       */
+       public abstract function _errorNumber();
+       
+       /**
+       * Returns the error string
+       */
+       public abstract function _errorString();
+       
        // ###################################################################
        /**
        * Sends the command to start a transaction. This command should never
@@ -463,18 +474,12 @@ abstract class BSDb
        {
                if ($this->showerrors)
                {
-                       if ($this->dblink)
-                       {
-                               $this->errnum = call_user_func($this->commands['error_num'], $this->dblink);
-                               $this->errstr = call_user_func($this->commands['error_str'], $this->dblink);
-                       }
-                       
                        $style['code'] = 'font-family: \'Courier New\', Courier, mono; font-size: 11px;';
                        
                        $message_prepped = "<blockquote>\n<p>";
                        $message_prepped .= "\n\t&raquo; <strong>Query:</strong>\n<br /> <pre style=\"$style[code]\">" . htmlspecialchars($this->querystr) ."</pre>\n<br />";
-                       $message_prepped .= "\n\t&raquo; <strong>Error Number:</strong> <span style=\"$style[code]\">" . $this->errnum . "</span>\n<br />";
-                       $message_prepped .= "\n\t&raquo; <strong>Error Message:</strong> <span style=\"$style[code]\">" . $this->errstr . "</span>\n<br />";
+                       $message_prepped .= "\n\t&raquo; <strong>Error Number:</strong> <span style=\"$style[code]\">" . $this->_errorNumber() . "</span>\n<br />";
+                       $message_prepped .= "\n\t&raquo; <strong>Error Message:</strong> <span style=\"$style[code]\">" . $this->_errorString() . "</span>\n<br />";
                        $message_prepped .= "\n\t&raquo; <strong>Additional Notes:</strong> <span style=\"$style[code]\">" . $message . "</span>\n<br />";
                        $message_prepped .= "\n\t&raquo; <strong>File:</strong> <span style=\"$style[code]\">" . $_SERVER['PHP_SELF'] . "</span>\n";
                        $message_prepped .= "\n</p>\n</blockquote>";
index 2c1c3d1e66181b1ffaaa5a53daf6f723123cd8a5..2f3527a87dd8bd297b57e2e623d6023d84cb4a1b 100644 (file)
@@ -225,6 +225,28 @@ class BSDbMySql extends BSDb
        {
                $this->query("COMMIT");
        }
+       
+       // ###################################################################
+       /**
+       * Returns the error number
+       *
+       * @return       integer Error number
+       */
+       public function _errorNumber()
+       {
+               return mysql_errno($this->dblink);
+       }
+       
+       // ###################################################################
+       /**
+       * Returns the error string
+       *
+       * @return       string  Error string
+       */
+       public function _errorString()
+       {
+               return mysql_error($this->dblink);
+       }
 }
 
 /*=====================================================================*\
index f2557c9de07dac53181b14eeda508c3e139602ee..161f008d428057104c3cd3091f6bc7e28b267b59 100644 (file)
@@ -197,6 +197,28 @@ class BSDbMySqlI extends BSDb
        {
                $this->query("COMMIT");
        }
+       
+       // ###################################################################
+       /**
+       * Returns the error number
+       *
+       * @return       integer Error number
+       */
+       public function _errorNumber()
+       {
+               return mysqli_errno($this->dblink);
+       }
+       
+       // ###################################################################
+       /**
+       * Returns the error string
+       *
+       * @return       string  Error string
+       */
+       public function _errorString()
+       {
+               return mysqli_error($this->dblink);
+       }
 }
 
 /*=====================================================================*\
index 61894718a082f23b8434de8dd8cc291335f9c383..eae0ca43661ba7140abe574c52cdea57f8a5329c 100644 (file)
@@ -41,28 +41,6 @@ require_once('ISSO/Db.php');
 */
 class BSDbPostgreSql extends BSDb
 {
-       /**
-       * Command mapping list
-       * @var  array
-       */
-       protected $commands = array(
-               'pconnect'                      => '$this->command_pg_pconnect',
-               'connect'                       => '$this->command_pg_connect',
-               'query'                         => 'pg_query',
-               'error_num'                     => '$this->command_error_num',
-               'error_str'                     => '$this->command_error_str',
-               'escape_string'         => '$this->command_pg_escape_string',
-               'escape_binary'         => 'pg_escape_bytea',
-               'unescape_binary'       => 'pg_unescape_bytea',
-               'fetch_assoc'           => 'pg_fetch_assoc',
-               'fetch_row'                     => 'pg_fetch_row',
-               'fetch_object'          => 'pg_fetch_object',
-               'free_result'           => 'pg_free_result',
-               'insert_id'                     => '%link', // how do we support this...?
-               'num_rows'                      => 'pg_num_rows',
-               'affected_rows'         => 'pg_affected_rows'
-       );
-       
        /**
        * Port number to connect to
        * @var  integer
@@ -238,6 +216,28 @@ class BSDbPostgreSql extends BSDb
        {
                $this->query("COMMIT");
        }
+       
+       // ###################################################################
+       /**
+       * Returns the error number
+       *
+       * @return       integer Error number
+       */
+       public function _errorNumber()
+       {
+               return -1;
+       }
+       
+       // ###################################################################
+       /**
+       * Returns the error string
+       *
+       * @return       string  Error string
+       */
+       public function _errorString()
+       {
+               return pg_last_error($this->dblink);
+       }
 }
 
 /*=====================================================================*\