cvs: php4 /pear/DB odbc.php

From: Date: Mon, 15 Jan 2001 01:14:59 +0000
Subject: cvs: php4 /pear/DB odbc.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3629@lists.php.net to get a copy of this message
ssb Sun Jan 14 17:14:59 2001 EDT Modified files: /php4/pear/DB odbc.php Log: * DB_odbc: added native error support Index: php4/pear/DB/odbc.php diff -u php4/pear/DB/odbc.php:1.24 php4/pear/DB/odbc.php:1.25 --- php4/pear/DB/odbc.php:1.24 Tue Jan 9 17:01:53 2001 +++ php4/pear/DB/odbc.php Sun Jan 14 17:14:59 2001 @@ -118,24 +118,12 @@ } else { $connect_function = 'odbc_connect'; } - if ($dbhost && $user && $pw) { - $conn = $connect_function($dbhost, $user, $pw); - } elseif ($dbhost && $user) { - $conn = $connect_function($dbhost, $user); - } elseif ($dbhost) { - $conn = $connect_function($dbhost); - } else { - $conn = false; + $conn = @$connect_function($dbhost, $user, $pw); + if (!is_resource($conn)) { + return $this->raiseError(); } - if ($conn == false) { - return $this->raiseError(); // XXX ERRORMSG - } $this->connection = $conn; return DB_OK; - - - - $this->connection = odbc_connect($dsn, $user, $pw); } // }}} @@ -253,6 +241,27 @@ } // }}} + // {{{ errorNative() + + /** + * Get the native error code of the last error (if any) that + * occured on the current connection. + * + * @access public + * + * @return int ODBC error code + */ + + function errorNative() + { + if (is_resource($this->connection)) { + return odbc_error($this->connection); + } else { + return odbc_error(); + } + } + + // }}} // {{{ autoCommit() function autoCommit($onoff = false) @@ -286,23 +295,24 @@ } // }}} - // {{{ odbcRaiseError() function odbcRaiseError($errno = null) { - if (is_string($errno) && - ereg('SQL error: (\[.*\])(.*), SQL state (.....)' - $errormsg, &$data)) { - list($foo, $source, $message, $codecode) = $data; + if (is_resource($this->connection)) { + $message = odbc_errormsg($this->connection); + $code = odbc_error($this->connection); + } else { + $message = odbc_errormsg(); + $code = odbc_error(); + } if ($errno === null) { - return $this->raiseError($this->errorCode(mysql_errno($this->connection))); + return $this->raiseError($this->errorCode($code)); } return $this->raiseError($this->errorCode($errno)); } // }}} - } // Local variables:

« previous php.cvs (#3629) next »