How to build complex Element Criteria? How to fetch Elements with a complex DB query?
E.g. with some nested AND/OR conditions or just apply two conditions to one field?

For example my Elements have a field eventDate. I want to fetch all Elements where eventDate is NULL or equals "1900-01-01". 

The standard way to build Element Criteria is:

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
$criteria-&gt;eventDate = '=...';
$models = $criteria-&gt;find();


It doesn't provide an ability to apply several conditions for same field. Is it possible at all without assembling huge queries manually?
You can apply conditions within the same field but you can't create conditions for multiple fields.

Here are some great examples

$criteria-&gt;expiryDate = 'or, :empty:, =' . $yourDateValue;


However you can't combine conditions for multiple fields. So you can't say Where (fieldX = 4 OR FieldY = 5) you would have to create an sql object based on your ElementCriteriaModel and use Yii's great Query Builder for that and use the OrWhere function

$query = craft()-&gt;elements-&gt;buildElementsQuery($criteria);