How do I alter a view query to use "OR"? The following is the content of the $query object that is passed to a view. 


[where] => Array(
  [0] => Array(
    [clauses] => Array(
      [0] => node.type in ('%s')
      [1] => node.status  0
      [2] => node.promote  0
      [3] => node.sticky  0
    )
    [args] => Array(
      [0] => test
    )
    [type] => AND
  )
)
[having] => Array()
[group_operator] => AND
 

I want to override it by using hook_views_query_alter(). The default operators are all AND, but I want to get the following query 


[0] => node.type in ('%s') AND
[1] => node.status  0 AND
[2] => node.promote  0  OR
[3] => node.sticky  0


How do I make the last operator to use "OR"?

db_query("SELECT content_id, count(*) AS cnt FROM {votingapi_vote} WHERE value =1 AND value_type = '%s'" , "option");


How do I use the query in hook_views_query_alter()?
This is untested, but I think what you want to do within your alter function is along the lines of this:

function mymodule_views_query_alter(&amp;$query) {
  unset($query-&gt;where[0]['clauses'][2]);
  unset($query-&gt;where[0]['clauses'][3]);

  $query-&gt;where[1] = array(
    'clauses' =&gt; array(
      0 =&gt; 'node.promote &lt;&gt; 0',
      1 =&gt; 'node.sticky &lt;&gt; 0',
    ),
    'type' =&gt; 'OR',
  );
}


This is essentially moving the promote and sticky clauses into a new where grouping, and by setting the type to 'OR', it should work the way you outline in your question.