aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-02 23:22:23 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-02 23:22:23 +0000
commitdf912421dc253ad84121e22b495c7f245c14700e (patch)
treeb57daa872b4f127c07c8100b17bc02c9f872e021 /engine/lib/entities.php
parenta29edfe8154abe9365a09d6806199c5536964408 (diff)
downloadelgg-df912421dc253ad84121e22b495c7f245c14700e.tar.gz
elgg-df912421dc253ad84121e22b495c7f245c14700e.tar.bz2
Deprecated elgg_get_entities_from_annotations().
git-svn-id: http://code.elgg.org/elgg/trunk@3614 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 3c2adc5ed..b1c09316b 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1661,16 +1661,17 @@ function elgg_get_entities(array $options = array()) {
'site_guids' => $CONFIG->site_guid,
'site_guid' => NULL,
- 'order_by' => 'time_created desc',
- 'limit' => 10,
- 'offset' => 0,
-
'modified_time_lower' => NULL,
'modified_time_upper' => NULL,
'created_time_lower' => NULL,
'created_time_upper' => NULL,
+ 'order_by' => 'e.time_created desc',
+ 'group_by' => NULL,
+ 'limit' => 10,
+ 'offset' => 0,
'count' => FALSE,
+ 'selects' => array(),
'wheres' => array(),
'joins' => array()
);
@@ -1723,16 +1724,28 @@ function elgg_get_entities(array $options = array()) {
}
}
+ // evalutate selects
+ if ($options['selects']) {
+ $selects = '';
+ foreach ($options['selects'] as $select) {
+ $selects = ", $select";
+ }
+ } else {
+ $selects = '';
+ }
+
if (!$options['count']) {
- $query = "SELECT DISTINCT e.* FROM {$CONFIG->dbprefix}entities e ";
+ $query = "SELECT DISTINCT e.*{$selects} FROM {$CONFIG->dbprefix}entities e ";
} else {
$query = "SELECT count(DISTINCT e.guid) as total FROM {$CONFIG->dbprefix}entities e ";
}
+ // add joins
foreach ($joins as $j) {
$query .= " $j ";
}
+ // add wheres
$query .= ' WHERE ';
foreach ($wheres as $w) {
@@ -1742,8 +1755,13 @@ function elgg_get_entities(array $options = array()) {
// Add access controls
$query .= get_access_sql_suffix('e');
if (!$options['count']) {
- $order_by = sanitise_string($options['order_by']);
- $query .= " ORDER BY $order_by";
+ if ($group_by = sanitise_string($options['group_by'])) {
+ $query .= " GROUP BY $group_by";
+ }
+
+ if ($order_by = sanitise_string($options['order_by'])) {
+ $query .= " ORDER BY $order_by";
+ }
if ($options['limit']) {
$limit = sanitise_int($options['limit']);