Avoid COUNT(*) in EntityPersister #5207

Open
opened 2026-01-22 15:01:34 +01:00 by admin · 0 comments
Owner

Originally created by @FlashBlack on GitHub (Aug 2, 2016).

Why there is no possibility to input expression in COUNT(*) in EntityPersister?
This is very important, for postgresql.

Something like that:

public function getCountSQL($criteria = array())
{
    ....
    $primaryKeyNames = $this->quoteStrategy->getIdentifierColumnNames($this->class, $this->platform);
    $countColumn = isset($primaryKeyNames[0]) ? sprintf('%s.%s', $tableAlias, $primaryKeyNames[0]) : '*';
        $sql = 'SELECT COUNT('.$countColumn.') '
            . 'FROM ' . $tableName . ' ' . $tableAlias
            . (empty($conditionSql) ? '' : ' WHERE ' . $conditionSql);

        return $sql;
    }
Originally created by @FlashBlack on GitHub (Aug 2, 2016). Why there is no possibility to input expression in COUNT(*) in EntityPersister? This is very important, for postgresql. Something like that: ``` php public function getCountSQL($criteria = array()) { .... $primaryKeyNames = $this->quoteStrategy->getIdentifierColumnNames($this->class, $this->platform); $countColumn = isset($primaryKeyNames[0]) ? sprintf('%s.%s', $tableAlias, $primaryKeyNames[0]) : '*'; $sql = 'SELECT COUNT('.$countColumn.') ' . 'FROM ' . $tableName . ' ' . $tableAlias . (empty($conditionSql) ? '' : ' WHERE ' . $conditionSql); return $sql; } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5207