Exemplo n.º 1
0
 /**
  * Get stats by entity.
  *
  * @param string $entity
  * @param array $aParams
  * @param boolean $allFields
  * @param string $key   The primary key field name
  * @return array    An array of entity records
  */
 function _getEntitiesStats($entity, $aParams, $allFields = false, $key = null)
 {
     if (empty($key)) {
         $key = "{$entity}_id";
     }
     $aColumns = SqlBuilder::_getStatsColumns($entity);
     $aTables = SqlBuilder::_getTables($entity, $aParams, true);
     $aLimitations = array_merge(SqlBuilder::_getStatsLimitations($entity, $aParams), SqlBuilder::_getTableLimitations($aTables, $aParams));
     // An ugly hack to get the alias used for the entity table so
     // the query works with Postgres.
     end($aColumns);
     $groupByColumn = key($aColumns);
     reset($aColumns);
     $aGroups = array($groupByColumn);
     return SqlBuilder::_select($aColumns, $aTables, $aLimitations, $aGroups, $key);
 }
Exemplo n.º 2
0
 /**
  * Get stats by entity.
  *
  * @param string $entity
  * @param array $aParams
  * @param boolean $allFields
  * @param string $key   The primary key field name
  * @return array    An array of entity records
  */
 function _getEntitiesStats($entity, $aParams, $allFields = false, $key = null)
 {
     if (empty($key)) {
         $key = "{$entity}_id";
     }
     $aColumns = SqlBuilder::_getStatsColumns($entity);
     $aTables = SqlBuilder::_getTables($entity, $aParams, true);
     $aLimitations = array_merge(SqlBuilder::_getStatsLimitations($entity, $aParams), SqlBuilder::_getTableLimitations($aTables, $aParams));
     $aGroupBy = array($key);
     return SqlBuilder::_select($aColumns, $aTables, $aLimitations, $aGroupBy, $key);
 }