Details
Description
Dears,
Line 309 in Doctrine_RawSql:
$q = 'SELECT COUNT( DISTINCT '.implode(',',$fields).') as num_results';
$string = $this->getInheritanceCondition($this->getRootAlias());
if ( ! empty($string)) {
$this->_sqlParts['where'][] = $string;
}
$q .= ( ! empty($this->_sqlParts['from']))? ' FROM ' . implode(' ', $this->_sqlParts['from']) : '';
$q .= ( ! empty($this->_sqlParts['where']))? ' WHERE ' . implode(' AND ', $this->_sqlParts['where']) : '';
$q .= ( ! empty($this->_sqlParts['groupby']))? ' GROUP BY ' . implode(', ', $this->_sqlParts['groupby']) : '';
$q .= ( ! empty($this->_sqlParts['having']))? ' HAVING ' . implode(' AND ', $this->_sqlParts['having']) : '';
produces with PostgreSQL: Undefined function: 7 ERROR: function count(bigint, integer) does not exist
but
$q = 'SELECT COUNT(*) as num_results FROM (SELECT DISTINCT '.implode(', ',$fields);
$string = $this->getInheritanceCondition($this->getRootAlias());
if ( ! empty($string)) {
$this->_sqlParts['where'][] = $string;
}
$q .= ( ! empty($this->_sqlParts['from']))? ' FROM ' . implode(' ', $this->_sqlParts['from']) : '';
$q .= ( ! empty($this->_sqlParts['where']))? ' WHERE ' . implode(' AND ', $this->_sqlParts['where']) : '';
$q .= ( ! empty($this->_sqlParts['groupby']))? ' GROUP BY ' . implode(', ', $this->_sqlParts['groupby']) : '';
$q .= ( ! empty($this->_sqlParts['having']))? ' HAVING ' . implode(' AND ', $this->_sqlParts['having']) : '';
$q .= ') as results';
works and should work with every database server.
Continue your great work ![]()
Regards,
Raphaël Dehousse