aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-03 11:30:30 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-03 11:30:30 +0000
commita37369e0865967aef0a5d6ba0e6ffab2c9393d4c (patch)
tree431439ed998bff204dbdb3c1b3b8123756bf367f /engine
parentdb7a6034e3967e74be0d04bc5c55d73032463eb4 (diff)
downloadelgg-a37369e0865967aef0a5d6ba0e6ffab2c9393d4c.tar.gz
elgg-a37369e0865967aef0a5d6ba0e6ffab2c9393d4c.tar.bz2
Added callbacks to get_data
git-svn-id: https://code.elgg.org/elgg/trunk@50 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/database.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 17857bef6..7288a5f42 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -108,11 +108,12 @@
/**
* Use this function to get data from the database
- * @param $query The query being passed.
+ * @param string $query The query being passed.
+ * @param string $call Optionally, the name of a function to call back to on each row (which takes $row as a single parameter)
* @return array An array of database result objects
*/
- function get_data($query) {
+ function get_data($query, $callback = "") {
global $dbcalls;
@@ -123,6 +124,9 @@
if ($result = mysql_query($query, $dblink)) {
while ($row = mysql_fetch_object($result)) {
+ if (!empty($callback) && is_callable($callback)) {
+ $row = $callback($row);
+ }
$resultarray[] = $row;
}
}