public function getFilterOptions($idList, $usedOnly, &$arrCount = null)
{
$strCol = $this->getColName();
if ($idList) {
$objRow = $this->getMetaModel()->getServiceContainer()->getDatabase()->prepare('SELECT ' . $strCol . ', COUNT(' . $strCol . ') as mm_count
FROM ' . $this->getMetaModel()->getTableName() . ' WHERE id IN (' . $this->parameterMask($idList) . ')
GROUP BY ' . $strCol . '
ORDER BY FIELD(id,' . $this->parameterMask($idList) . ')')->execute(array_merge($idList, $idList));
} elseif ($usedOnly) {
$objRow = $this->getMetaModel()->getServiceContainer()->getDatabase()->execute('SELECT ' . $strCol . ', COUNT(' . $strCol . ') as mm_count
FROM ' . $this->getMetaModel()->getTableName() . '
GROUP BY ' . $strCol . '
ORDER BY ' . $strCol);
} else {
// We can not do anything here, must be handled by the derived attribute class.
return array();
}
$arrResult = array();
while ($objRow->next()) {
if (is_array($arrCount)) {
$arrCount[$objRow->{$strCol}] = $objRow->mm_count;
}
$arrResult[$objRow->{$strCol}] = $objRow->{$strCol};
}
return $arrResult;
}