The last step in writing queries is to filter the data that is returned to present appropriate information to the user. Some common examples include showing a specific node, getting a list of nodes that a specific user created, getting a list of nodes that were created by a user after a specific date, and so on.
Conditions correlate to the WHERE
clause of an SQL statement or a HAVING
clause in a query with a GROUP BY
clause. Conditions can be added to a query using either the condition
method or the where
method. The signatures of each method are as follows:
condition($field, $value = NULL, $operator = NULL) where($snippet, $args = array())
The main difference between these two methods is that the condition
method allows standard operations to be easily encoded. The where
clause allows you to enter an arbitrary SQL snippet for the condition. The SQL snippet is not validated for consistency across databases so you should ensure that it is well supported if you...