Note that there are some explanatory texts on larger screens.

plurals
  1. PODrupal 7 - Multiple Joins in Query Giving Me Trouble
    primarykey
    data
    text
    <p>When adding new fields to the user registration page of a Drupal site the new fields are not stored in the "User" table, but in their own individual tables. I have a custom form module page set up where the user can select which people receive their message based on Age, Gender, if they are a Student, and if they have chosen to receive message under the moniker Live. I have never used "join" before with a mySQL query so I am unsure what the appropriate syntax is for the Drupal Database API. This is what I currently have:</p> <pre><code>$query = db_select("field_data_field_age", "a"); $query-&gt;join("field_data_field_gender", "g", "a.entity_id = g.entity_id"); $query-&gt;join("field_data_field_phone_number", "p", "a.entity_id = p.entity_id AND g.entity_id = p.entity_id"); $query-&gt;join("field_data_field_student", "s", "a.entity_id = s.entity_id AND g.entity_id = s.entity_id AND p.entity_id = s.entity_id"); $query-&gt;join("field_data_field_live", "l", "a.entity_id = l.entity_id AND g.entity_id = l.entity_id AND p.entity_id = l.entity_id AND s.entity_id = l.entity_id"); $query-&gt;groupBy("p.entity_id"); $query-&gt;fields("p", array("field_phone_number_value")) -&gt;condition("a.field_age_value", $values["age_lower"], &gt;=) -&gt;condition("a.field_age_value", $values["age_upper"], &lt;=) -&gt;condition("l.field_live_value", "Yes", =) -&gt;condition("g.field_gender_value", values["gender"], =); $phone_numbers = $query-&gt;execute(); </code></pre> <p>This code is breaking my site and I am unsure of what I am doing wrong. Again, I tried searching Google under "multiple joins mysql", but didn't find anything exclusively dealing with the Drupal Database API. Any help would be greatly appreciated, thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload