cvs: php4 /pear DB.php /pear/DB common.php mysql.php
| From: | Stig Bakken | Date: | Sun, 15 Oct 2000 02:22:26 +0000 |
| Subject: | cvs: php4 /pear DB.php /pear/DB common.php mysql.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2059@lists.php.net to get a copy of this message | ||
ssb Sat Oct 14 19:22:26 2000 EDT
Modified files:
/php4/pear DB.php
/php4/pear/DB common.php mysql.php
Log:
PEAR DB: added DB_ERROR_NOT_LOCKED, gave DB_common::raiseError an optional
"nativecode" parameter.
Index: php4/pear/DB.php
diff -u php4/pear/DB.php:1.32 php4/pear/DB.php:1.33
--- php4/pear/DB.php:1.32 Wed Sep 13 04:27:59 2000
+++ php4/pear/DB.php Sat Oct 14 19:22:25 2000
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.32 2000/09/13 11:27:59 ssb Exp $
+// $Id: DB.php,v 1.33 2000/10/15 02:22:25 ssb Exp $
//
// Database independent query interface.
//
@@ -52,6 +52,7 @@
define("DB_ERROR_NOSUCHTABLE", -18);
define("DB_ERROR_NOSUCHFIELD", -19);
define("DB_ERROR_NEED_MORE_DATA", -20);
+define("DB_ERROR_NOT_LOCKED", -21);
/*
@@ -242,25 +243,26 @@
function errorMessage($value) {
if (!isset($errorMessages)) {
$errorMessages = array(
- DB_OK => "no error",
DB_ERROR => "unknown error",
- DB_ERROR_SYNTAX => "syntax error",
- DB_ERROR_CONSTRAINT => "constraint violation",
- DB_ERROR_NOT_FOUND => "not found",
DB_ERROR_ALREADY_EXISTS => "already exists",
- DB_ERROR_UNSUPPORTED => "not supported",
- DB_ERROR_MISMATCH => "mismatch",
- DB_ERROR_INVALID => "invalid",
- DB_ERROR_NOT_CAPABLE => "DB backend not capable",
- DB_ERROR_INVALID_NUMBER => "invalid number",
- DB_ERROR_INVALID_DATE => "invalid date or time",
- DB_ERROR_DIVZERO => "division by zero",
- DB_ERROR_NODBSELECTED => "no database selected",
DB_ERROR_CANNOT_CREATE => "can not create",
DB_ERROR_CANNOT_DELETE => "can not delete",
DB_ERROR_CANNOT_DROP => "can not drop",
- DB_ERROR_NOSUCHTABLE => "no such table",
+ DB_ERROR_CONSTRAINT => "constraint violation",
+ DB_ERROR_DIVZERO => "division by zero",
+ DB_ERROR_INVALID => "invalid",
+ DB_ERROR_INVALID_DATE => "invalid date or time",
+ DB_ERROR_INVALID_NUMBER => "invalid number",
+ DB_ERROR_MISMATCH => "mismatch",
+ DB_ERROR_NODBSELECTED => "no database selected",
DB_ERROR_NOSUCHFIELD => "no such field",
+ DB_ERROR_NOSUCHTABLE => "no such table",
+ DB_ERROR_NOT_CAPABLE => "DB backend not capable",
+ DB_ERROR_NOT_FOUND => "not found",
+ DB_ERROR_NOT_LOCKED => "not locked",
+ DB_ERROR_SYNTAX => "syntax error",
+ DB_ERROR_UNSUPPORTED => "not supported",
+ DB_OK => "no error",
DB_WARNING => "unknown warning",
DB_WARNING_READ_ONLY => "read only"
);
@@ -359,7 +361,7 @@
$dsn = $arr[3];
} elseif (preg_match('|^([^:]+)@(.*)$|', $dsn, $arr)) {
$parsed['username'] = $arr[1];
- $dsn = $arr[3];
+ $dsn = $arr[2];
}
if (preg_match('|^([^\+]+)\+(.*)$|', $dsn, $arr)) {
@@ -448,14 +450,6 @@
return true;
}
}
-
-/*
- * DB_Error TODO:
- *
- * - needs a way of storing queries (useful for debugging query syntax
- * errors)
- *
- */
/**
* DB_Error implements a class for reporting portable database error
Index: php4/pear/DB/common.php
diff -u php4/pear/DB/common.php:1.23 php4/pear/DB/common.php:1.24
--- php4/pear/DB/common.php:1.23 Wed Sep 20 12:21:47 2000
+++ php4/pear/DB/common.php Sat Oct 14 19:22:26 2000
@@ -114,7 +114,7 @@
//php_error(E_WARNING, get_class($this)."::errorCode: no mapping for $nativecode");
// Fall back to DB_ERROR if there was no mapping. Ideally,
// this should never happen.
- return $this->raiseError();
+ return $this->raiseError(DB_ERROR, false, false, false, $nativecode);
}
// }}}
@@ -141,7 +141,7 @@
*
*/
function &raiseError($code = DB_ERROR, $mode = false, $level = false,
- $debuginfo = false) {
+ $debuginfo = false, $nativecode = false) {
if (!$mode) {
$mode = $this->error_mode;
}
@@ -159,6 +159,9 @@
if (!$debuginfo) {
$debuginfo = $this->last_query;
}
+ if ($nativecode) {
+ $debuginfo .= " [nativecode=$nativecode]";
+ }
return new DB_Error($code, $mode, $level, $debuginfo);
}
@@ -355,8 +358,9 @@
* when finished.
*
* @param $query the SQL query
- * @param $params is supplies, prepare/execute will be used
+ * @param $params if supplied, prepare/execute will be used
* with this array as execute parameters
+ * @access public
*/
function &getOne($query, $params = array()) {
if (sizeof($params) > 0) {
@@ -391,6 +395,7 @@
* of doing the query and freeing the results when finished.
*
* @param $query the SQL query
+ * @access public
* @return array the first row of results as an array indexed from
* 0, or a DB error code.
*/
@@ -433,6 +438,8 @@
* @param $col which column to return (integer [column number,
* starting at 0] or string [column name])
*
+ * @access public
+ *
* @return array an indexed array with the data from the first
* row at index 0, or a DB error code.
*/
@@ -478,6 +485,8 @@
* exactly two columns. If true, the values of the returned array
* will be one-element arrays instead of scalars.
*
+ * @access public
+ *
* @return array associative array with results from the query.
* If the result set contains more than two columns, the value
* will be an array of the values from column 2-n. If the result
@@ -560,7 +569,7 @@
* Fetch all the rows returned from a query.
*
* @param $query the SQL query
- *
+ * @access public
* @return array an nested array, or a DB error
*/
function &getAll($query, $fetchmode = DB_FETCHMODE_DEFAULT, $params = array()) {
Index: php4/pear/DB/mysql.php
diff -u php4/pear/DB/mysql.php:1.26 php4/pear/DB/mysql.php:1.27
--- php4/pear/DB/mysql.php:1.26 Wed Sep 13 04:27:59 2000
+++ php4/pear/DB/mysql.php Sat Oct 14 19:22:26 2000
@@ -66,7 +66,8 @@
1064 => DB_ERROR_SYNTAX,
1054 => DB_ERROR_NOSUCHFIELD,
1062 => DB_ERROR_ALREADY_EXISTS,
- 1051 => DB_ERROR_NOSUCHTABLE
+ 1051 => DB_ERROR_NOSUCHTABLE,
+ 1100 => DB_ERROR_NOT_LOCKED
);
}