cvs: php4 /pear/Cache DB.php
| From: | Sebastian Bergmann | Date: | Tue, 14 Aug 2001 20:44:34 +0000 |
| Subject: | cvs: php4 /pear/Cache DB.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-517@lists.php.net to get a copy of this message | ||
sebastian Tue Aug 14 16:44:34 2001 EDT
Modified files:
/php4/pear/Cache DB.php
Log:
Implement fetchInto(). Further work on fetchRow().
Index: php4/pear/Cache/DB.php
diff -u php4/pear/Cache/DB.php:1.4 php4/pear/Cache/DB.php:1.5
--- php4/pear/Cache/DB.php:1.4 Tue Aug 14 15:25:08 2001
+++ php4/pear/Cache/DB.php Tue Aug 14 16:44:34 2001
@@ -15,7 +15,7 @@
// | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.4 2001/08/14 19:25:08 sebastian Exp $
+// $Id: DB.php,v 1.5 2001/08/14 20:44:34 sebastian Exp $
require_once 'Cache.php';
require_once 'DB.php';
@@ -27,7 +27,7 @@
* @module Cache_DB
* @modulegroup Cache_DB
* @package Cache
-* @version $Revision: 1.4 $
+* @version $Revision: 1.5 $
* @access public
*/
class Cache_DB extends Cache {
@@ -50,7 +50,6 @@
*
* @var string
*/
-
var $dsn = '';
/**
@@ -186,7 +185,7 @@
* @module Cache_DB
* @modulegroup Cache_DB
* @package Cache
-* @version $Revision: 1.4 $
+* @version $Revision: 1.5 $
* @access public
*/
class Cache_DB_Result {
@@ -246,36 +245,68 @@
* @return array a row of data, NULL on no more rows or PEAR_Error on error
*/
function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) {
- if ($this->cursor < sizeof($this->rows)) {
- if ($fetchmode == DB_FETCHMODE_ASSOC) {
- return $this->rows[$this->cursor++];
+/* if ($fetchmode === DB_FETCHMODE_OBJECT) {
+ $fetchmode = DB_FETCHMODE_ASSOC;
+ $return_object = true;
+ }
+*/
+ if ($rownum === null) {
+ $rownum = $this->cursor++;
+ }
+
+ if ($rownum < sizeof($this->rows)) {
+ $_row = $this->rows[$rownum];
+ } else {
+ return false;
+ }
+
+ switch ($fetchmode) {
+ case DB_FETCHMODE_ASSOC: {
+ $row =& $_row;
}
+ break;
- elseif ($fetchmode == DB_FETCHMODE_ORDERED) {
- $row = array();
- $_row = $this->rows[$this->cursor++];
+ case DB_FETCHMODE_ORDERED: {
+ $row = array();
foreach ($this->column_names as $column_name) {
$row[] = $_row[$column_name];
}
+ }
+ break;
- return $row;
+ default: {
+ return false;
}
- } else {
- return false;
}
+
+/* if (isset($return_object)) {
+ $class = $this->db->fetchmode_object_class;
+ $object =& new $class($row);
+
+ return $object;
+ } else {
+*/ return $row;
+// }
}
/**
* Fetch a row of data into an existing variable.
*
- * @param $arr reference to data containing the row
+ * @param $row reference to data containing the row
* @param $fetchmode format of fetched row
* @param $rownum the row number to fetch
* @return mixed DB_OK on success, NULL on no more rows or
* a DB_Error object on errors
*/
- function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) {
+ function fetchInto(&$row, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) {
+ $row = $this->fetchRow($fetchmode, $rownum);
+
+ if (is_array($row)) {
+ return DB_OK;
+ } else {
+ return NULL;
+ }
}
/**