cvs: php4 /pear/Cache DB.php
| From: | Sebastian Bergmann | Date: | Wed, 15 Aug 2001 16:48:12 +0000 |
| Subject: | cvs: php4 /pear/Cache DB.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-530@lists.php.net to get a copy of this message | ||
sebastian Wed Aug 15 12:48:12 2001 EDT
Modified files:
/php4/pear/Cache DB.php
Log:
Implement free(). Mark tableInfo() as not implemented. Fixx PHPDoc.
Index: php4/pear/Cache/DB.php
diff -u php4/pear/Cache/DB.php:1.7 php4/pear/Cache/DB.php:1.8
--- php4/pear/Cache/DB.php:1.7 Wed Aug 15 03:51:33 2001
+++ php4/pear/Cache/DB.php Wed Aug 15 12:48:07 2001
@@ -15,7 +15,7 @@
// | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.7 2001/08/15 07:51:33 sebastian Exp $
+// $Id: DB.php,v 1.8 2001/08/15 16:48:07 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.7 $
+* @version $Revision: 1.8 $
* @access public
*/
class Cache_DB extends Cache {
@@ -105,25 +105,27 @@
}
/**
- * Connect to a database
+ * Connect to a database.
*
- * @param string PEAR DB DSN for the database connection
- * @param mixed options
+ * @param string PEAR DB DSN for the database connection
+ * @param mixed options
+ * @throws object DB_Error
*/
function connect($dsn, $options = false) {
if (!isset($this->db)) {
$this->db = DB::connect($dsn, $options);
if (DB::isError($this->db)) {
+ return $this->db;
}
}
}
/**
- * Register a database connection for connect on demand
+ * Register a database connection for connect on demand.
*
- * @param string PEAR DB DSN for the database connection
- * @param mixed options
+ * @param string PEAR DB DSN for the database connection
+ * @param mixed options
*/
function setConnection($dsn, $options = false) {
$this->dsn = $dsn;
@@ -158,10 +160,11 @@
}
/**
- * Perform an SQL query
+ * Perform an SQL query.
*
- * @param string SQL Query String
- * @return mixed
+ * @param string SQL Query String
+ * @return object Cache_DB_Result
+ * @throws object Cache_Error
*/
function &query($query) {
if (stristr($query, 'SELECT')) {
@@ -226,7 +229,7 @@
* @module Cache_DB
* @modulegroup Cache_DB
* @package Cache
-* @version $Revision: 1.7 $
+* @version $Revision: 1.8 $
* @access public
*/
class Cache_DB_Result {
@@ -282,7 +285,9 @@
/**
* Constructor
*
- * @param array Rows
+ * @param array rows
+ * @param integer fetchmode
+ * @param string fetchmode_object_class
*/
function Cache_DB_Result(&$rows, $fetchmode, $fetchmode_object_class) {
$this->rows = $rows;
@@ -296,10 +301,11 @@
}
/**
- * Fetch and return a row of data
- * @param $fetchmode format of fetched row
- * @param $rownum the row number to fetch
- * @return array a row of data, NULL on no more rows or PEAR_Error on error
+ * Fetch and return a row of data.
+ * @param integer format of fetched row
+ * @param mixed row to fetch
+ * @return mixed a row of data, NULL on no more rows
+ * @throws object DB_Error
*/
function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) {
if ($fetchmode === DB_FETCHMODE_DEFAULT) {
@@ -354,16 +360,13 @@
/**
* Fetch a row of data into an existing variable.
*
- * @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
+ * @param array reference to data containing the row
+ * @param integer format of fetched row
+ * @param integer row number to fetch
+ * @return mixed DB_OK on success, NULL on no more rows
*/
function fetchInto(&$row, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) {
- $row = $this->fetchRow($fetchmode, $rownum);
-
- if (is_array($row)) {
+ if ($row = $this->fetchRow($fetchmode, $rownum)) {
return DB_OK;
} else {
return NULL;
@@ -373,7 +376,7 @@
/**
* Get the the number of columns in a result set.
*
- * @return int the number of columns, or a DB error
+ * @return integer number of columns
*/
function numCols() {
return $this->num_columns;
@@ -382,7 +385,7 @@
/**
* Get the number of rows in a result set.
*
- * @return int the number of rows, or a DB error
+ * @return integer number of rows
*/
function numRows() {
return $this->num_rows;
@@ -392,9 +395,23 @@
* Frees the resources allocated for this result set.
*/
function free() {
+ $this->column_names = array();
+ $this->rows = array();
+ $this->num_columns = 0;
+ $this->num_rows = 0;
}
+ /**
+ * tableInfo() is not implemented in the PEAR Cache DB module.
+ * @param mixed $mode
+ * @throws object Cache_Error
+ */
function tableInfo($mode = null) {
+ return new Cache_Error('tableInfo() is not implemented in the
+ PEAR Cache DB module.',
+ __FILE__,
+ __LINE__
+ );
}
}
?>