chagenbu Fri Feb 16 09:14:40 2001 EDT
Modified files:
/php4/pear DB.php
/php4/pear/DB ibase.php msql.php mssql.php mysql.php oci8.php
odbc.php pgsql.php sybase.php
Log:
All DB modules should return NULL from fetchRow() now if there are no more
results, and a DB_Error object only on an error.
DB::isError() return false when passed null now.
Index: php4/pear/DB.php
diff -u php4/pear/DB.php:1.47 php4/pear/DB.php:1.48
--- php4/pear/DB.php:1.47 Fri Feb 2 09:59:30 2001
+++ php4/pear/DB.php Fri Feb 16 09:14:39 2001
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.47 2001/02/02 17:59:30 cmv Exp $
+// $Id: DB.php,v 1.48 2001/02/16 17:14:39 chagenbu Exp $
//
// Database independent query interface.
//
@@ -256,9 +256,8 @@
function isError($value)
{
return (is_object($value) &&
- (get_class($value) == "db_error" ||
- is_subclass_of($value, "db_error")) ||
- !isset($value));
+ (get_class($value) == 'db_error' ||
+ is_subclass_of($value, 'db_error')));
}
/**
Index: php4/pear/DB/ibase.php
diff -u php4/pear/DB/ibase.php:1.15 php4/pear/DB/ibase.php:1.16
--- php4/pear/DB/ibase.php:1.15 Tue Jan 9 17:01:53 2001
+++ php4/pear/DB/ibase.php Fri Feb 16 09:14:39 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <[EMAIL PROTECTED]> |
// +----------------------------------------------------------------------+
//
-// $Id: ibase.php,v 1.15 2001/01/10 01:01:53 ssb Exp $
+// $Id: ibase.php,v 1.16 2001/02/16 17:14:39 chagenbu Exp $
//
// Database independent query interface definition for PHP's Interbase
// extension.
@@ -93,23 +93,28 @@
return DB::isManip($query) ? DB_OK : $result;
}
- function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT)
+ function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT)
{
- if ($fetchmode == DB_FETCHMODE_DEFAULT) {
- $fetchmode = $this->fetchmode;
- }
- if ($fetchmode & DB_FETCHMODE_ASSOC) {
- $row = (array)ibase_fetch_object($result);
- } else {
- $row = ibase_fetch_row($result);
- }
- if (!$row) {
- return $this->raiseError();
- }
- return $row;
+ if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+ $fetchmode = $this->fetchmode;
}
-
- function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT)
+ if ($fetchmode & DB_FETCHMODE_ASSOC) {
+ $row = (array)ibase_fetch_object($result);
+ } else {
+ $row = ibase_fetch_row($result);
+ }
+ if (!$row) {
+ if ($errmsg = ibase_errmsg()) {
+ return $this->raiseError($errmsg);
+ } else {
+ return null;
+ }
+ }
+
+ return $row;
+ }
+
+ function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT)
{
if ($fetchmode == DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
Index: php4/pear/DB/msql.php
diff -u php4/pear/DB/msql.php:1.14 php4/pear/DB/msql.php:1.15
--- php4/pear/DB/msql.php:1.14 Tue Jan 9 17:01:53 2001
+++ php4/pear/DB/msql.php Fri Feb 16 09:14:39 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <[EMAIL PROTECTED]> |
// +----------------------------------------------------------------------+
//
-// $Id: msql.php,v 1.14 2001/01/10 01:01:53 ssb Exp $
+// $Id: msql.php,v 1.15 2001/02/16 17:14:39 chagenbu Exp $
//
// Database independent query interface definition for PHP's Mini-SQL
// extension.
@@ -103,8 +103,13 @@
$row = @msql_fetch_row($result);
}
if (!$row) {
- return $this->raiseError();
+ if ($error = msql_error()) {
+ return $this->raiseError($error);
+ } else {
+ return null;
+ }
}
+
return $row;
}
Index: php4/pear/DB/mssql.php
diff -u php4/pear/DB/mssql.php:1.17 php4/pear/DB/mssql.php:1.18
--- php4/pear/DB/mssql.php:1.17 Tue Jan 9 17:01:53 2001
+++ php4/pear/DB/mssql.php Fri Feb 16 09:14:39 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <[EMAIL PROTECTED]> |
// +----------------------------------------------------------------------+
//
-// $Id: mssql.php,v 1.17 2001/01/10 01:01:53 ssb Exp $
+// $Id: mssql.php,v 1.18 2001/02/16 17:14:39 chagenbu Exp $
//
// Database independent query interface definition for PHP's Microsoft SQL Server
// extension.
@@ -102,9 +102,15 @@
} else {
$row = @mssql_fetch_row($result);
}
+
if (!$row) {
- return $this->raiseError(mssql_get_last_message());
+ if ($msg = mssql_get_last_message()) {
+ return $this->raiseError($msg);
+ } else {
+ return null;
+ }
}
+
return $row;
}
Index: php4/pear/DB/mysql.php
diff -u php4/pear/DB/mysql.php:1.45 php4/pear/DB/mysql.php:1.46
--- php4/pear/DB/mysql.php:1.45 Fri Jan 26 12:07:23 2001
+++ php4/pear/DB/mysql.php Fri Feb 16 09:14:40 2001
@@ -205,7 +205,7 @@
$errno = mysql_errno($this->connection);
if (!$errno) {
- return $this->raiseError('end of results');
+ return null;
}
return $this->mysqlRaiseError($errno);
Index: php4/pear/DB/oci8.php
diff -u php4/pear/DB/oci8.php:1.16 php4/pear/DB/oci8.php:1.17
--- php4/pear/DB/oci8.php:1.16 Tue Jan 9 17:01:53 2001
+++ php4/pear/DB/oci8.php Fri Feb 16 09:14:40 2001
@@ -150,35 +150,35 @@
// }}}
// {{{ fetchRow()
- /**
- * Fetch a row and return as array.
- *
- * @param $result oci8 result identifier
- * @param $fetchmode how the resulting array should be indexed
- *
- * @return int an array on success, a DB error code on failure, NULL
- * if there is no more data
- */
- function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT)
+ /**
+ * Fetch a row and return as array.
+ *
+ * @param $result oci8 result identifier
+ * @param $fetchmode how the resulting array should be indexed
+ *
+ * @return int an array on success, a DB error code on failure, NULL
+ * if there is no more data
+ */
+ function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT)
{
- if ($fetchmode == DB_FETCHMODE_DEFAULT) {
- $fetchmode = $this->fetchmode;
- }
- if ($fetchmode & DB_FETCHMODE_ASSOC) {
-
$moredata=OCIFetchInto($result,$row,OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS);
- } else {
-
$moredata=OCIFetchInto($result,$row,OCI_RETURN_NULLS+OCI_RETURN_LOBS);
- }
- if (!$row) {
- return $this->raiseError();
- }
- if ($moredata==NULL) {
- return NULL;
- }
- return $row;
+ if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+ $fetchmode = $this->fetchmode;
}
-
- // }}}
+ if ($fetchmode & DB_FETCHMODE_ASSOC) {
+ $moredata = OCIFetchInto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS +
+OCI_RETURN_LOBS);
+ } else {
+ $moredata = OCIFetchInto($result, $row, OCI_RETURN_NULLS +
+OCI_RETURN_LOBS);
+ }
+ if (!$row) {
+ return $this->raiseError();
+ }
+ if ($moredata == NULL) {
+ return NULL;
+ }
+ return $row;
+ }
+
+ // }}}
// {{{ fetchInto()
/**
Index: php4/pear/DB/odbc.php
diff -u php4/pear/DB/odbc.php:1.25 php4/pear/DB/odbc.php:1.26
--- php4/pear/DB/odbc.php:1.25 Sun Jan 14 17:14:59 2001
+++ php4/pear/DB/odbc.php Fri Feb 16 09:14:40 2001
@@ -179,10 +179,16 @@
if ($fetchmode == DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
- $cols = odbc_fetch_into($result, &$row);
- if ($cols == 0) {
- return $this->raiseError(); // XXX ERRORMSG
- }
+
+ $cols = odbc_fetch_into($result, &$row);
+ if (!$cols) {
+ if ($errno = odbc_error($this->connection)) {
+ return $this->raiseError($errno);
+ } else {
+ return null;
+ }
+ }
+
if ($fetchmode == DB_FETCHMODE_ORDERED) {
return $row;
} else if ($fetchmode == DB_FETCHMODE_ASSOC) {
@@ -192,11 +198,11 @@
}
return $a;
} else {
- return $this->raiseError(); // XXX ERRORMSG
+ return $this->raiseError(); // XXX ERRORMSG
}
- }
-
- // }}}
+ }
+
+ // }}}
// {{{ freeResult()
function freeResult($result)
Index: php4/pear/DB/pgsql.php
diff -u php4/pear/DB/pgsql.php:1.26 php4/pear/DB/pgsql.php:1.27
--- php4/pear/DB/pgsql.php:1.26 Tue Jan 9 17:01:53 2001
+++ php4/pear/DB/pgsql.php Fri Feb 16 09:14:40 2001
@@ -239,7 +239,7 @@
if ($fetchmode == DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
- if ($this->row[$result]>=$this->numrows[$result]){
+ if ($this->row[$result] >= $this->numrows[$result]) {
return NULL;
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
Index: php4/pear/DB/sybase.php
diff -u php4/pear/DB/sybase.php:1.13 php4/pear/DB/sybase.php:1.14
--- php4/pear/DB/sybase.php:1.13 Tue Jan 9 17:01:53 2001
+++ php4/pear/DB/sybase.php Fri Feb 16 09:14:40 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <[EMAIL PROTECTED]> |
// +----------------------------------------------------------------------+
//
-// $Id: sybase.php,v 1.13 2001/01/10 01:01:53 ssb Exp $
+// $Id: sybase.php,v 1.14 2001/02/16 17:14:40 chagenbu Exp $
//
// Database independent query interface definition for PHP's Sybase
// extension.
@@ -80,34 +80,38 @@
// }}}
// {{{ simpleQuery()
- function simpleQuery($query)
+ function simpleQuery($query)
{
- $this->last_query = $query;
+ $this->last_query = $query;
$query = $this->modifyQuery($query);
- $result = @sybase_query($query, $this->connection);
- if (!$result) {
- return $this->raiseError();
- }
- // Determine which queries that should return data, and which
- // should return an error code only.
- return DB::isManip($query) ? DB_OK : $result;
+ $result = @sybase_query($query, $this->connection);
+ if (!$result) {
+ return $this->raiseError();
}
-
+ // Determine which queries that should return data, and which
+ // should return an error code only.
+ return DB::isManip($query) ? DB_OK : $result;
+ }
+
// }}}
// {{{ fetchRow()
-
- function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT)
+ function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT)
{
- if ($fetchmode == DB_FETCHMODE_DEFAULT) {
- $fetchmode = $this->fetchmode;
- }
- $row = ($fetchmode & DB_FETCHMODE_ASSOC) ?
@sybase_fetch_array($result) : @sybase_fetch_row($result);
- if (!$row) {
- return $this->raiseError();
- }
- return $row;
+ if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+ $fetchmode = $this->fetchmode;
}
-
+ $row = ($fetchmode & DB_FETCHMODE_ASSOC) ? @sybase_fetch_array($result) :
+@sybase_fetch_row($result);
+ if (!$row) {
+ if ($errmsg = sybase_get_last_message()) {
+ return $this->raiseError($errmsg);
+ } else {
+ return null;
+ }
+ }
+
+ return $row;
+ }
+
// }}}
// {{{ fetchInto()
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]