Modify an ElementCriteriaModel to compare against numeric field Can anyone tell me why this is returning all entries instead of entries with a creditsUsed field > 0? creditsUsed is a number field that I created for this entry type.

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
$criteria-&gt;authorId = craft()-&gt;userSession-&gt;getUser()-&gt;id;
$criteria-&gt;section = 'news';
$criteria-&gt;creditsUsed &gt; 0;
$criteria-&gt;status = null;
$entries = $criteria-&gt;total();
Here's what's actually happening with this line of code...

$criteria-&gt;creditsUsed &gt; 0;


You are actually generating the boolean value of "is creditsUsed more than zero". Granted, you aren't setting it to an actual variable, but nonetheless you are generating a boolean value. For example:

$moreThanZeroCreditsUsed = ($criteria-&gt;creditsUsed &gt; 0);


Even though you're not assigning that new boolean value to a variable, it's still valid PHP (and therefore no error is thrown).

What it looks like you are trying to do instead is to actually set the value of creditsUsed, which you'd need to use an equals sign to do:

$criteria-&gt;creditsUsed = "whatever";


If my memory serves me correctly, the way to denote a comparison on an ElementCriteriaModel is to simply pass the comparison as a string:

$criteria-&gt;creditsUsed = "&gt; 0";


See the last example in this subsection... Granted, it's being applied via Twig syntax, but it's still modifying the ElementCriteriaModel in the same way:

craft.entries.width('&gt;= 100')