Created
April 15, 2014 11:08
-
-
Save StanAngeloff/10723440 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* (c) PSP UK Group Ltd. <[email protected]> | |
* | |
* For the full copyright and license information, | |
* please view the LICENSE file that was distributed with this source code. | |
*/ | |
namespace Psp\Query\Aggregate; | |
class CountAggregateColumn extends AbstractSqlFunctionAggregateColumn | |
{ | |
use PlatformAgnosticAggregateColumnTrait; | |
# {{{ AbstractSqlFunctionAggregateColumn | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function getSqlFunction() | |
{ | |
return 'COUNT'; | |
} | |
# }}} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* (c) PSP UK Group Ltd. <[email protected]> | |
* | |
* For the full copyright and license information, | |
* please view the LICENSE file that was distributed with this source code. | |
*/ | |
namespace Psp\Query\Aggregate; | |
use Doctrine\DBAL\Platforms\PostgreSqlPlatform; | |
/** | |
* A string aggregate PostgreSQL aggregate columns. | |
*/ | |
class DistinctPostgreSqlAggregateColumn extends AbstractPostgreSqlAggregateColumn | |
{ | |
# {{{ AggregateColumnInterface | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getName() | |
{ | |
return 'DISTINCT'; | |
} | |
# }}} | |
# {{{ AbstractPostgreSqlAggregateColumn | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function doApply($column, PostgreSqlPlatform $platform) | |
{ | |
return sprintf( | |
"string_agg(DISTINCT %s::text, ',')", | |
$column | |
); | |
} | |
# }}} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment