cvs: /php4/pear DB.php
| From: | Stig Bakken | Date: | Wed, 09 Feb 2000 19:04:47 +0000 |
| Subject: | cvs: /php4/pear DB.php | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-9990@lists.php.net to get a copy of this message | ||
ssb Wed Feb 9 11:04:47 2000 EDT
Modified files:
/php4/pear DB.php
Log:
Added three get modes: DB_GETMODE_ORDERED, DB_GETMODE_ASSOC and
DB_GETMODE_FLIPPED. Docs are within.
Index: php4/pear/DB.php
diff -u php4/pear/DB.php:1.11 php4/pear/DB.php:1.12
--- php4/pear/DB.php:1.11 Thu Feb 3 02:49:03 2000
+++ php4/pear/DB.php Wed Feb 9 11:04:17 2000
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.11 2000/02/03 10:49:03 ssb Exp $
+// $Id: DB.php,v 1.12 2000/02/09 19:04:17 ssb Exp $
//
// Database independent query interface.
//
@@ -89,8 +89,35 @@
define("DB_BINMODE_CONVERT", 3);
// }}}
+// {{{ Get modes: flags that control the layout of query result structures
/**
+ * Column data indexed by numbers, ordered from 0 and up
+ */
+define('DB_GETMODE_ORDERED', 1);
+/**
+ * Column data indexed by column names
+ */
+define('DB_GETMODE_ASSOC', 2);
+/**
+ * For multi-dimensional results: normally the first level of arrays
+ * is the row number, and the second level indexed by column number or name.
+ * DB_GETMODE_FLIPPED switches this order, so the first level of arrays
+ * is the column name, and the second level the row number.
+ */
+define('DB_GETMODE_FLIPPED', 4);
+
+/**
+ * This constant DB's default get mode. It is possible to override by
+ * defining in your scripts before including DB.
+ */
+if (!defined('DB_GETMODE_DEFAULT')) {
+ define('DB_GETMODE_DEFAULT', DB_GETMODE_ORDERED);
+}
+
+// }}}
+
+/**
* The main "DB" class is simply a container class with some static
* methods for creating DB objects as well as some utility functions
* common to all parts of DB.
@@ -395,8 +422,8 @@
* Fetch and return a row of data.
* @return array a row of data, or false on error
*/
- function fetchRow() {
- return $this->dbh->fetchRow($this->result);
+ function fetchRow($getmode = DB_GETMODE_DEFAULT) {
+ return $this->dbh->fetchRow($this->result, $getmode);
}
// }}}
@@ -408,8 +435,8 @@
* @param $arr reference to data array
* @return int error code
*/
- function fetchInto(&$arr) {
- return $this->dbh->fetchInto($this->result, &$arr);
+ function fetchInto(&$arr, $getmode = DB_GETMODE_DEFAULT) {
+ return $this->dbh->fetchInto($this->result, &$arr, $getmode);
}
// }}}