aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-28 21:58:42 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-28 21:58:42 +0000
commit8e8d3839196290b26099b852aadbdc345e25e490 (patch)
treeb03d886836a6163063e5b21d33683971a20db8bd /engine/lib
parent6f98219d28071d8c019167f6fa7bea18bb5e2de7 (diff)
downloadelgg-8e8d3839196290b26099b852aadbdc345e25e490.tar.gz
elgg-8e8d3839196290b26099b852aadbdc345e25e490.tar.bz2
Cleaned up table prefix for elgg_get_entity_metadata_where_sql().
Cleaned up some documentation. git-svn-id: http://code.elgg.org/elgg/trunk@3597 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/metadata.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index bbdd3365a..9af0acdc8 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -535,7 +535,7 @@ function find_metadata($meta_name = "", $meta_value = "", $entity_type = "", $en
/**
- * Get all entities.
+ * Returns entities based upon metadata.
*
* @param array $options Array in format:
*
@@ -621,7 +621,7 @@ function elgg_get_entities_from_metadata(array $options = array()) {
* @param BOOL $case_sensitive
* @return FALSE|array False on fail, array('joins', 'wheres')
*/
-function elgg_get_entity_metadata_where_sql($prefix, $names = NULL, $values = NULL, $pairs = NULL, $pair_operator = 'AND', $case_sensitive = TRUE) {
+function elgg_get_entity_metadata_where_sql($table, $names = NULL, $values = NULL, $pairs = NULL, $pair_operator = 'AND', $case_sensitive = TRUE) {
global $CONFIG;
// short circuit if nothing requested
@@ -648,7 +648,7 @@ function elgg_get_entity_metadata_where_sql($prefix, $names = NULL, $values = NU
// get names wheres and joins
$names_where = '';
if ($names !== NULL) {
- $return['joins'][] = "JOIN {$CONFIG->dbprefix}metadata md on e.guid = md.entity_guid";
+ $return['joins'][] = "JOIN {$CONFIG->dbprefix}metadata md on {$table}.guid = md.entity_guid";
if (!is_array($names)) {
$names = array($names);
}
@@ -671,7 +671,7 @@ function elgg_get_entity_metadata_where_sql($prefix, $names = NULL, $values = NU
// get values wheres and joins
$values_where = '';
if ($values !== NULL) {
- $return['joins'][] = "JOIN {$CONFIG->dbprefix}metadata md on e.guid = md.entity_guid";
+ $return['joins'][] = "JOIN {$CONFIG->dbprefix}metadata md on {$table}.guid = md.entity_guid";
if (!is_array($values)) {
$values = array($values);
@@ -717,6 +717,8 @@ function elgg_get_entity_metadata_where_sql($prefix, $names = NULL, $values = NU
$pair_wheres = array();
+ // @todo when the pairs are > 3 should probably split the query up to
+ // denormalize the strings table.
$i = 1;
foreach ($pairs as $index => $pair) {
// @todo move this elsewhere?
@@ -729,7 +731,7 @@ function elgg_get_entity_metadata_where_sql($prefix, $names = NULL, $values = NU
}
// @todo The multiple joins are only needed when the operator is AND
- $return['joins'][] = "JOIN {$CONFIG->dbprefix}metadata md{$i} on e.guid = md{$i}.entity_guid";
+ $return['joins'][] = "JOIN {$CONFIG->dbprefix}metadata md{$i} on {$table}.guid = md{$i}.entity_guid";
$return['joins'][] = "JOIN {$CONFIG->dbprefix}metastrings msn{$i} on md{$i}.name_id = msn{$i}.id";
$return['joins'][] = "JOIN {$CONFIG->dbprefix}metastrings msv{$i} on md{$i}.value_id = msv{$i}.id";