I write this as my query.
$query="SELECT distinct e.* from entities e JOIN objects_entity o on e.guid = o.guid JOIN (SELECT subm1.*, s1.string FROM metadata subm1 JOIN metastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid JOIN (SELECT subm2.*, s2.string FROM metadata subm2 JOIN metastrings s2 ON subm2.value_id = s2.id) AS m2 ON e.guid = m2.entity_guid JOIN (SELECT subm3.*, s3.string FROM metadata subm3 JOIN metastrings s3 ON subm3.value_id = s3.id) AS m3 ON e.guid = m3.entity_guid JOIN (SELECT subm4.*, s4.string FROM metadata subm4 JOIN metastrings s4 ON subm4.value_id = s4.id) AS m4 ON e.guid = m4.entity_guid where ((m1.name_id='298' AND m1.string IN (". $filter.")) and (m4.name_id='318' AND m4.string >= ".$dd.")) and e.subtype= '12' and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes') and ( (1 = 1) and m2.enabled='yes') and ( (1 = 1) and m3.enabled='yes') and ( (1 = 1) and m4.enabled='yes') and e.owner_guid = ".$user_query['guid']." order by m4.string asc limit 0,3";
$entities = get_data($query, "entity_row_to_elggstar");
and it give this error...
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) and (m4.name_id='318' AND m4.string >= )) and e.subtype= '12' and ( (1 = 1) a' at line 1
QUERY: SELECT distinct e.* from entities e JOIN objects_entity o on e.guid = o.guid JOIN (SELECT subm1.*, s1.string FROM metadata subm1 JOIN metastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid JOIN (SELECT subm2.*, s2.string FROM metadata subm2 JOIN metastrings s2 ON subm2.value_id = s2.id) AS m2 ON e.guid = m2.entity_guid JOIN (SELECT subm3.*, s3.string FROM metadata subm3 JOIN metastrings s3 ON subm3.value_id = s3.id) AS m3 ON e.guid = m3.entity_guid JOIN (SELECT subm4.*, s4.string FROM metadata subm4 JOIN metastrings s4 ON subm4.value_id = s4.id) AS m4 ON e.guid = m4.entity_guid where ((m1.name_id='298' AND m1.string IN ()) and (m4.name_id='318' AND m4.string >= )) and e.subtype= '12' and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes') and ( (1 = 1) and m2.enabled='yes') and ( (1 = 1) and m3.enabled='yes') and ( (1 = 1) and m4.enabled='yes') and e.owner_guid = 2 order by m4.string asc limit 0,3
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Brett@brett.profitt

Brett - 0 likes
- Jeroen Dalsem@jdalsem

Jeroen Dalsem - 0 likes
- elgg_user@elgg_user

elgg_user - 0 likes
You must log in to post replies.Do you have to write raw SQL? You can use elgg_get_entities_from_metadata() to do this.
The problem is that $dd is empty.
that was an easy one :) do you have any hard ones too? If the error says the problem is near "blablalblalba" then most of the time it is right before that text.
Oh yeah.... with Elgg there is no need for a custom query. Never (with some exceptions)!
Thank you guys..