cvs: pear /MDB/MDB mssql.php
| From: | Lukas Smith | Date: | Fri, 06 Jun 2003 10:02:34 +0000 |
| Subject: | cvs: pear /MDB/MDB mssql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-10724@lists.php.net to get a copy of this message | ||
lsmith Fri Jun 6 06:02:34 2003 EDT
Modified files:
/pear/MDB/MDB mssql.php
Log:
error handling methods updated
error_map array needs to be added!
Index: pear/MDB/MDB/mssql.php
diff -u pear/MDB/MDB/mssql.php:1.3 pear/MDB/MDB/mssql.php:1.4
--- pear/MDB/MDB/mssql.php:1.3 Thu Jun 5 18:21:18 2003
+++ pear/MDB/MDB/mssql.php Fri Jun 6 06:02:33 2003
@@ -43,7 +43,7 @@
// | Author: Frank M. Kromann <frank@kromann.info> |
// +----------------------------------------------------------------------+
//
-// $Id: mssql.php,v 1.3 2003/06/05 22:21:18 lsmith Exp $
+// $Id: mssql.php,v 1.4 2003/06/06 10:02:33 lsmith Exp $
//
require_once('MDB/Common.php');
@@ -101,34 +101,12 @@
$this->supported['Replace'] = 0;
$this->supported['SubSelects'] = 1;
-
-/* $this->decimal_factor = pow(10.0, $this->decimal_places);
-
- $this->options['DefaultTableType'] = FALSE;
- $this->options['fixed_float'] = FALSE;
-
- $this->errorcode_map = array(
- 1004 => MDB_ERROR_CANNOT_CREATE,
- 1005 => MDB_ERROR_CANNOT_CREATE,
- 1006 => MDB_ERROR_CANNOT_CREATE,
- 1007 => MDB_ERROR_ALREADY_EXISTS,
- 1008 => MDB_ERROR_CANNOT_DROP,
- 1046 => MDB_ERROR_NODBSELECTED,
- 1050 => MDB_ERROR_ALREADY_EXISTS,
- 1051 => MDB_ERROR_NOSUCHTABLE,
- 1054 => MDB_ERROR_NOSUCHFIELD,
- 1062 => MDB_ERROR_ALREADY_EXISTS,
- 1064 => MDB_ERROR_SYNTAX,
- 1100 => MDB_ERROR_NOT_LOCKED,
- 1136 => MDB_ERROR_VALUE_COUNT_ON_ROW,
- 1146 => MDB_ERROR_NOSUCHTABLE,
- 1048 => MDB_ERROR_CONSTRAINT,
- );
-*/
+ // XXX Add here error codes ie: 'S100E' => DB_ERROR_SYNTAX
+ $this->errorcode_map = array();
}
// }}}
- // {{{ errorNative()
+ // {{{ errorCode()
/**
* Get the native error code of the last error (if any) that
@@ -138,9 +116,16 @@
*
* @return int native MSSQL error code
*/
- function errorNative()
+ function errorCode()
{
- return mssql_errno($this->connection);
+ $this->pushErrorHandling(PEAR_ERROR_RETURN);
+ $error_code = $this->queryOne('select @@ERROR as ErrorCode');
+ $this->popErrorHandling();
+ // XXX Debug
+ if (!isset($this->errorcode_map[$error_code])) {
+ return MDB_ERROR;
+ }
+ return $error_code;
}
// }}}
@@ -156,12 +141,15 @@
* @access public
* @see PEAR_Error
*/
- function mssqlRaiseError($errno = NULL)
+ function mssqlRaiseError($code = NULL)
{
- if ($errno == NULL) {
- $errno = $this->errorCode(mssql_errno($this->connection));
+ if ($code !== NULL) {
+ $code = $this->errorCode();
+ if (DB::isError($code)) {
+ return $this->raiseError($code);
+ }
}
- return($this->raiseError($errno, NULL, NULL, NULL, @mssql_error($this->connection)));
+ return $this->raiseError($code, NULL, NULL, NULL, mssql_get_last_message());
}
// }}}