A quick article on how to use the where clause in a joomla database query.
Why?
In response to a member, I use the old form where I can include the whole SQL statement:
$db->query('SELECT * FROM #__myTable WHERE condition1=true or condition2=true')Method #1 - chain:
$query
->where($db->quoteName('condition1') . ' = '. $db->quote('true'),'OR')
->where($db->quoteName('condition2') . ' = '. $db->quote('true'))
Method #2 - array:
$conditions = array(
$db->quoteName('condition1') . ' = true',
$db->quoteName('condition2') . ' = true'
);
$query->where($conditions, 'OR')
Discussion
Comments
Questions, corrections and useful additions are reviewed before appearing here.
No comments yet. Start the discussion.