diff --git a/contao/library/Contao/Model.php b/contao/library/Contao/Model.php index e6cd4e7837..be3af347b9 100644 --- a/contao/library/Contao/Model.php +++ b/contao/library/Contao/Model.php @@ -1009,26 +1009,34 @@ protected static function postFind(\Database\Result $objResult) /** * Return the number of records matching certain criteria * - * @param mixed $strColumn An optional property name - * @param mixed $varValue An optional property value + * @param mixed $strColumn An optional property name + * @param mixed $varValue An optional property value + * @param array $arrOptions An optional options array * * @return integer The number of matching rows */ - public static function countBy($strColumn=null, $varValue=null) + public static function countBy($strColumn=null, $varValue=null, array $arrOptions=array()) { if (static::$strTable == '') { return 0; } - $strQuery = static::buildCountQuery(array + $arrOptions = array_merge ( - 'table' => static::$strTable, - 'column' => $strColumn, - 'value' => $varValue - )); + array + ( + 'table' => static::$strTable, + 'column' => $strColumn, + 'value' => $varValue + ), + + $arrOptions + ); + + $strQuery = static::buildCountQuery($arrOptions); - return (int) \Database::getInstance()->prepare($strQuery)->execute($varValue)->count; + return (int) \Database::getInstance()->prepare($strQuery)->execute($arrOptions['value'])->count; }