1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest Easier way to add own Order By Clause

Discussion in 'Closed Suggestions' started by xf_phantom, Jan 14, 2014.

  1. xf_phantom

    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?
     

Share This Page