Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
wfpl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e86ee66
)
* db.php (db_get_assoc, db_get_assocs): new functions to ease use of new template...
author
Josh Grams
<josh@qualdan.com>
Sat, 22 Aug 2009 17:29:23 +0000
(13:29 -0400)
committer
Josh Grams
<josh@qualdan.com>
Sat, 22 Aug 2009 17:29:23 +0000
(13:29 -0400)
db.php
patch
|
blob
|
history
diff --git
a/db.php
b/db.php
index
4a58db8
..
f39d5e0
100644
(file)
--- a/
db.php
+++ b/
db.php
@@
-166,6
+166,22
@@
function db_get_rows($table, $columns, $where = '') {
return $rows;
}
return $rows;
}
+# like db_get_rows, but return array of hashes.
+function db_get_assocs($table, $columns, $where = '') {
+ $args = func_get_args();
+ $args = array_slice($args, 3);
+ $result = db_send_get($table, $columns, $where, $args);
+
+ $rows = array();
+ while($row = mysql_fetch_assoc($result)) {
+ $rows[] = $row;
+ }
+
+ mysql_free_result($result);
+
+ return $rows;
+}
+
function db_get_column($table, $columns, $where = '') {
$args = func_get_args();
$args = array_slice($args, 3);
function db_get_column($table, $columns, $where = '') {
$args = func_get_args();
$args = array_slice($args, 3);
@@
-193,6
+209,19
@@
function db_get_row($table, $columns, $where = '') {
return $row;
}
return $row;
}
+# like db_get_row, but return a hash.
+function db_get_assoc($table, $columns, $where = '') {
+ $args = func_get_args();
+ $args = array_slice($args, 3);
+ $result = db_send_get($table, $columns, $where, $args);
+
+ $row = mysql_fetch_assoc($result);
+
+ mysql_free_result($result);
+
+ return $row;
+}
+
function db_get_value($table, $columns, $where = '') {
$args = func_get_args();
$args = array_slice($args, 3);
function db_get_value($table, $columns, $where = '') {
$args = func_get_args();
$args = array_slice($args, 3);