SHARE
TWEET

Untitled

a guest Jul 24th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $selected_services = array(512, 825, 912, 913, 936);
  2.  
  3. $query = db_select('users', 'u');
  4. $query->join('users_roles', 'ur', 'ur.uid = u.uid');
  5. $query->join('role', 'r', 'r.rid = ur.rid');
  6. $query->condition('r.name', 'customer');
  7. $query->join('field_data_field_topic_activity', 'service', 'u.uid = service.entity_id');
  8. $query->condition('service.field_topic_activity_tid', $selected_services, 'IN');
  9. $query->groupBy('u.uid');
  10. $query->fields('u', array('uid'))->condition('u.status', 1);
  11.  
  12. $result = $query->execute()->fetchField();
  13.      
  14. $query = db_select('users', 'u');
  15. $query->join('users_roles', 'ur', 'ur.uid = u.uid');
  16. $query->join('role', 'r', 'r.rid = ur.rid');
  17. $query->condition('r.name', 'customer');
  18. $query->join('field_data_field_topic_activity', 'service', 'u.uid = service.entity_id');
  19. $query->condition('service.field_topic_activity_tid', $selected_services, 'IN');
  20. $query->groupBy('u.uid');
  21. $query->fields('u', array('uid'))->condition('u.status', 1);
  22.  
  23. if(!empty($cat)) {
  24.   $query->join('field_data_field_my_product', 'collection', 'u.uid = collection.entity_id');
  25.   $query->join('field_data_field_sub_category', 'product', 'product.entity_id = collection.field_my_product_value');
  26.   $query->condition('product.field_sub_category_tid', $cat, 'IN');
  27. }
  28.  
  29. if(!empty($city)) {
  30.   $query->join('field_data_field_address_website', 'address_collection', 'u.uid = address_collection.entity_id');
  31.   $query->join('field_data_field_user_address', 'address', 'address.entity_id = address_collection.field_address_website_value');
  32.   $query->condition('address.field_user_address_administrative_area', $city, 'IN');
  33. }
  34. $query->range(($pager - 1) * 20, 20);
  35. $result = $query->execute();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top