busterb Wed Jan 29 23:16:10 2003 EDT
Modified files:
/pear/DBA_Relational Table.php
Log:
added firstRow() and nextRow() methods
Index: pear/DBA_Relational/Table.php
diff -u pear/DBA_Relational/Table.php:1.20 pear/DBA_Relational/Table.php:1.21
--- pear/DBA_Relational/Table.php:1.20 Mon Jan 27 07:12:43 2003
+++ pear/DBA_Relational/Table.php Wed Jan 29 23:16:10 2003
@@ -18,7 +18,7 @@
// | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
// +----------------------------------------------------------------------+
//
-// $Id: Table.php,v 1.20 2003/01/27 12:12:43 busterb Exp $
+// $Id: Table.php,v 1.21 2003/01/30 04:16:10 busterb Exp $
//
require_once 'PEAR.php';
require_once 'DBA.php';
@@ -1005,6 +1005,48 @@
}
}
// }}}
+
+
+ // {{{ firstRow()
+ /**
+ * Returns the first row in the table. The built-in cursor for the
+ * internal _dba object is used, so no other operations should be performed
+ * other than nextRow() if iterating through the rows is the desired
+ * operation
+ *
+ * @access public
+ * @return mixed PEAR_Error on failure, the row array on success
+ * or false if there are no elements in the table
+ * i.e (firstRow() === false) = table is empty
+ */
+ function firstRow()
+ {
+ if ($this->_dba->isOpen()) {
+ $key = $this->_dba->firstkey();
+ return $this->_unpackRow($this->_dba->fetch($key));
+ } else {
+ return $this->raiseError('table not open');
+ }
+ }
+ // }}}
+
+ // {{{ firstRow()
+ /**
+ * Returns the next row in the table after a firstRow or nextRow.
+ *
+ * @access public
+ * @return mixed PEAR_Error on failure, the row array on success
+ * or false if there are no more elements in the table
+ */
+ function nextRow() {
+ if ($this->_dba->isOpen()) {
+ $key = $this->_dba->nextkey();
+ return $this->_unpackRow($this->_dba->fetch($key));
+ } else {
+ return $this->raiseError('table not open');
+ }
+ }
+ // }}}
// {{{
/**
--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|