Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Consider the options array in Model::countBy() (see #7033)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 17, 2014
1 parent 9495dc2 commit 8727d7b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions contao/library/Contao/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 8727d7b

Please sign in to comment.