ZfTable
ZfTable copied to clipboard
tableAlias . included even for composed columns
Hi,
The table alias "." is included into order even if the field is a composed one.
sample:
For
CONCAT(u.lastName, ' ', u.firstName) staff_name
Order looks like this:
ORDER BY .staff_name
So i created fix for ZfTable\Source\DoctrineQueryBuilder:
protected function order()
{
$column = $this->getParamAdapter()->getColumn();
$order = $this->getParamAdapter()->getOrder();
if (!$column) {
return;
}
$header = $this->getTable()->getHeader($column);
$tableAlias = ($header) ? $header->getTableAlias() : 'q';
if (false === strpos($tableAlias, '.')) {
if(empty($tableAlias)){
$tableAlias = $column;
} else {
$tableAlias = $tableAlias.'.'.$column;
}
}
$this->query->orderBy($tableAlias, $order);
}
Can you fork and create a PR so it's eadier to review the changes?
See now.
Can you fork and create a PR so it's eadier to review the changes?
— Reply to this email directly or view it on GitHub https://github.com/dudapiotr/ZfTable/issues/78#issuecomment-158667629.
Cristian Bichis IMAGIS Strada Faiantei nr 13 550098 Sibiu, Romania Phone: 004.0727.757533 Email: [email protected] Web: www.imagis.ro