/**
  * Return the amount of total items (filtering may be used in the config).
  *
  * @param InterfaceGeneralDataConfig $objConfig
  *
  * @return int
  */
 public function getCount(InterfaceGeneralDataConfig $objConfig)
 {
     $objFilter = $this->prepareFilter($objConfig->getFilter());
     return $this->objMetaModel->getCount($objFilter);
 }
 /**
  * Retrieve all unique values for the given property.
  *
  * The result set will be an array containing all unique values contained in the data provider.
  * Note: this only re-ensembles really used values for at least one data set.
  *
  * The only information being interpreted from the passed config object is the first property to fetch and the
  * filter definition.
  *
  * @param InterfaceGeneralDataConfig $objConfig   The filter config options.
  *
  * @return GeneralCollectionDefault
  *
  * @throws Exception if improper values have been passed (i.e. not exactly one field requested).
  */
 public function getFilterOptions(InterfaceGeneralDataConfig $objConfig)
 {
     $arrProperties = $objConfig->getFields();
     $strProperty = $arrProperties[0];
     if (count($arrProperties) != 1) {
         throw new Exception('objConfig must contain exactly one property to be retrieved.');
     }
     $arrParams = array();
     $objValues = $this->objDatabase->prepare(sprintf('SELECT DISTINCT(%s) FROM %s %s', $strProperty, $this->strSource, $this->buildWhereQuery($objConfig, $arrParams)))->execute($arrParams);
     $objCollection = $this->getEmptyCollection();
     while ($objValues->next()) {
         $objNewModel = $this->getEmptyModel();
         $objNewModel->setProperty($strProperty, $objValues->{$strProperty});
         $objCollection->add($objNewModel);
     }
     return $objCollection;
 }
 /**
  * Fetch a single record by id.
  *
  * This data provider only supports retrieving by id so use $objConfig->setId() to populate the config with an Id.
  *
  * @param InterfaceGeneralDataConfig $objConfig
  *
  * @return InterfaceGeneralModel
  *
  * @throws Exception if config object does not contain an Id.
  */
 public function fetch(InterfaceGeneralDataConfig $objConfig)
 {
     if (!$objConfig->getId()) {
         throw new Exception("Error, no id passed, GeneralDataTableRowsAsRecords is only intended for edit mode.", 1);
     }
     $strQuery = sprintf('SELECT %s FROM %s WHERE %s=?', $this->buildFieldQuery($objConfig), $this->strSource, $this->strGroupCol);
     if ($this->strSortCol) {
         $strQuery .= ' ORDER BY ' . $this->strSortCol;
     }
     $objResult = $this->objDatabase->prepare($strQuery)->execute($objConfig->getId());
     $objModel = $this->getEmptyModel();
     if ($objResult->numRows) {
         $objModel->setProperty('rows', $objResult->fetchAllAssoc());
     }
     $objModel->setID($objConfig->getId());
     return $objModel;
 }