Lack of interest Easier way to add own Order By Clause

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

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?
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']]))
		{
isn't true?
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Back
Top Bottom