xf_phantom
Well-known member
Wouldn't it make sense to allow coders to set the orderbyClause without overwriting the model?
Just take a look at http://xenforo.com/community/threads/getusers-order.66579/
It's not possible without creating a own model and overwriting prepareUserOrderOptions
Is there any special reason, why the order must be available in the choises array?
Couldn't you introduce probably a new feature where we could set e.g. $fetchOptions['alternative_order'] which would be used if
isn't true?
Just take a look at http://xenforo.com/community/threads/getusers-order.66579/
It's not possible without creating a own model and overwriting prepareUserOrderOptions
Is there any special reason, why the order must be available in the choises array?
PHP:
public function getOrderByClause(array $choices, array $fetchOptions, $defaultOrderSql = '')
{
$orderSql = null;
if (!empty($fetchOptions['order']) && isset($choices[$fetchOptions['order']]))
{
$orderSql = $choices[$fetchOptions['order']];
if (empty($fetchOptions['direction']))
{
$fetchOptions['direction'] = 'asc';
}
$dir = (strtolower($fetchOptions['direction']) == 'desc' ? 'DESC' : 'ASC');
$orderSqlOld = $orderSql;
$orderSql = sprintf($orderSql, $dir);
if ($orderSql === $orderSqlOld)
{
$orderSql .= ' ' . $dir;
}
}
if (!$orderSql)
{
$orderSql = $defaultOrderSql;
}
return ($orderSql ? 'ORDER BY ' . $orderSql : '');
}
Couldn't you introduce probably a new feature where we could set e.g. $fetchOptions['alternative_order'] which would be used if
PHP:
if (!empty($fetchOptions['order']) && isset($choices[$fetchOptions['order']]))
{
Upvote
0