cvs: /php4/pear/DB common.php
| From: | Stig Bakken | Date: | Wed, 09 Feb 2000 19:07:19 +0000 |
| Subject: | cvs: /php4/pear/DB common.php | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-9991@lists.php.net to get a copy of this message | ||
ssb Wed Feb 9 11:07:19 2000 EDT
Modified files:
/php4/pear/DB common.php
Log:
Introduced an extra optional parameter to getOne, getRow and getAssoc
that contains a list of parameters to use with (prepare/)execute.
Also changed these methods into returning references.
Index: php4/pear/DB/common.php
diff -u php4/pear/DB/common.php:1.6 php4/pear/DB/common.php:1.7
--- php4/pear/DB/common.php:1.6 Thu Feb 3 02:49:04 2000
+++ php4/pear/DB/common.php Wed Feb 9 11:06:49 2000
@@ -152,13 +152,23 @@
* when finished.
*
* @param $query the SQL query
+ * @param $params is supplies, prepare/execute will be used
+ * with this array as execute parameters
*/
- function getOne($query) {
- $res = $this->simpleQuery($query);
- if (DB::isError($sth)) {
- return $sth;
+ function &getOne($query, $params = array()) {
+ if (sizeof($params) > 0) {
+ $sth = $this->prepare($query);
+ if (DB::isError($sth)) {
+ return $sth;
+ }
+ $res = $this->execute($sth, &$params);
+ } else {
+ $res = $this->simpleQuery($query);
+ }
+ if (DB::isError($res)) {
+ return $res;
}
- $row = $this->fetchRow($res);
+ $row = $this->fetchRow($res, DB_GETMODE_ORDERED);
if (DB::isError($row)) {
return $row;
}
@@ -178,12 +188,12 @@
* @return array the first row of results as an array indexed from
* 0, or a DB error code.
*/
- function getRow($query) {
+ function getRow($query, $getmode = DB_GETMODE_DEFAULT, $params = array()) {
$res = $this->simpleQuery($query);
if (DB::isError($res)) {
return $res;
}
- $row = $this->fetchRow($res);
+ $row = $this->fetchRow($res, $getmode);
if (DB::isError($row)) {
return $row;
}
@@ -238,7 +248,7 @@
* Keep in mind that database functions in PHP usually return string
* values for results regardless of the database's internal type.
*/
- function getAssoc($query, $force_array = false) {
+ function &getAssoc($query, $force_array = false, $params = array()) {
$res = $this->simpleQuery($query);
if (DB::isError($res)) {
return $res;
@@ -269,7 +279,13 @@
}
// }}}
+ // {{{ getAll()
+
+ function &getAll($query, $getmode = DB_GETMODE_DEFAULT, $params = array()) {
+
+ }
+ // }}}
}
// Local variables: