rafaelwendel / phpsupabase

PHP Client to use Supabase
MIT License
187 stars 18 forks source link

Sort Order #4

Closed sharkstate closed 2 years ago

sharkstate commented 2 years ago

Ive used the QueryBuilder to order the results like so:

    $listProducts = $query->select('*')
                ->from('table')
                ->range('0-0')
                ->order('color')
                ->execute()
                ->getResult();

Which gives me the first result ordering by 'color' descending. How can I do the same thing but ascending?

Thanks!

rafaelwendel commented 2 years ago

Hello sharkstate,

By default, the "order" method shows the data in ascending order. Anyway, you can make your ordering explicit.

    $listProducts = $query->select('*')
                ->from('table')
                ->range('0-0')
                ->order('color.asc') //or "color.desc"
                ->execute()
                ->getResult();

Hope this helps!