Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created April 15, 2014 11:08
Show Gist options
  • Save StanAngeloff/10723440 to your computer and use it in GitHub Desktop.
Save StanAngeloff/10723440 to your computer and use it in GitHub Desktop.
<?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';
}
# }}}
}
<?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