Skip to content

Commit

Permalink
Implement buildSortingSelectSQL() API
Browse files Browse the repository at this point in the history
This is required for compatibility with Symphony 2.7.x, which bring
compatibility with MySQL 5.7 strict mode.

The code is a copy of the logic from buildSortingSQL, which should be
refactored when dropping pre 2.7.0 compatibility

Re: #84
  • Loading branch information
nitriques committed Jun 20, 2017
1 parent cb32bb0 commit 1650fa6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions fields/field.selectbox_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,33 @@ public function buildSortingSQL(&$joins, &$where, &$sort, $order='ASC'){
}
}

public function buildSortingSelectSQL($sort, $order = 'ASC')
{
if ($this->isRandomOrder($order)) {
return null;
}
$sort = array();
$joinnedFieldSchema = array();
$joinnedFieldsId = $this->getRelatedFieldsId();

foreach ($joinnedFieldsId as $key => $joinnedFieldId) {
$joinnedFieldSchema = $this->getFieldSchema($joinnedFieldId);

if (empty($joinnedFieldSchema)) {
// bail out
return;
}
$joinnedFieldSchema = current($joinnedFieldSchema);
$sortColumn = $joinnedFieldSchema['Field'];
$sort[] = "`jd_$key`.`$sortColumn`";
}

if (!empty($sort)) {
return implode(',', $sort);
}
return null;
}

/*-------------------------------------------------------------------------
Grouping:
-------------------------------------------------------------------------*/
Expand Down

0 comments on commit 1650fa6

Please sign in to comment.