Note that there are some explanatory texts on larger screens.

plurals
  1. POchange SQL query from PHP
    primarykey
    data
    text
    <p>How do I change a certain SQL query form inside PHP code Like for example here in the below code</p> <pre><code>&lt;?php function eb_mine_views_query_alter(&amp;$view, &amp;$query) { if ($view-&gt;name == 'statuser') { dsm($query, 'before'); $query-&gt;where[0]['type'] = 'OR'; dsm($query, 'after'); } } ?&gt; </code></pre> <p>this code is related to a Drupal modification.</p> <p>previous query</p> <pre><code>SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created FROM {node} node INNER JOIN {taxonomy_index} taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = :views_join_condition_0 INNER JOIN {taxonomy_index} taxonomy_index_value_1 ON node.nid = taxonomy_index_value_1.nid AND taxonomy_index_value_1.tid = :views_join_condition_1 WHERE ((( (taxonomy_index_value_0.tid = :db_condition_placeholder_2) )**AND**( (taxonomy_index_value_1.tid = :db_condition_placeholder_3) ))) ORDER BY node_created DESC </code></pre> <p>After the above code runs the resulting query</p> <pre><code>SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created FROM node node OUTER JOIN taxonomy_index taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = '9' OUTER JOIN taxonomy_index taxonomy_index_value_1 ON node.nid = taxonomy_index_value_1.nid AND taxonomy_index_value_1.tid = '6' WHERE ((( (taxonomy_index_value_0.tid = '9') )OR( (taxonomy_index_value_1.tid = '6') ))) ORDER BY node_created DESC LIMIT 5 OFFSET 0; </code></pre> <p>As you can see the query changed from AND to OR. </p> <p>Now I want to change the same code like this:</p> <pre><code>SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created FROM node node LEFT OUTER JOIN taxonomy_index taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = '9' LEFT OUTER JOIN taxonomy_index taxonomy_index_value_1 ON node.nid = taxonomy_index_value_1.nid AND taxonomy_index_value_1.tid = '6' WHERE ((( (taxonomy_index_value_0.tid = '9') )OR( (taxonomy_index_value_1.tid = '6') ))) ORDER BY node_created DESC LIMIT 5 OFFSET 0; </code></pre> <p>rather than using <strong>OUTER JOIN</strong> I want to use <strong>LEFT OUTER JOIN</strong>. So how do I do this in my PHP code</p>
    singulars
    1. This table or related slice is empty.
    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.
    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