5

I'm using Kohana's ORM library, and I'm wondering if there is any way to order the results that are generated.

Example:

$priorities = ORM::factory('priority')->select_list('id','label'); //how to order these?
GSto
  • 41,512
  • 37
  • 133
  • 184

1 Answers1

8

What is select_list?

Btw, ordering in kohana is performed by order_by() method

...->order_by('field', 'asc')

More samples you can find at: http://kerkness.ca/kowiki/doku.php?id=building_complex_select_statements#order_by

Also that wiki contains a lot of usefull articles about kohana: http://kerkness.ca/kowiki/doku.php

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
zerkms
  • 249,484
  • 69
  • 436
  • 539
  • a function that must have existed an one point, but doesn't now. saw it in these docs: http://docs.kohanaphp.com/libraries/orm – GSto Oct 05 '10 at 01:19
  • which kohana version are you talking about, v2 or v3? if v3 - then there is no such function. Go to the wiki url in my answer and read about kohana v3 orm in details. – zerkms Oct 05 '10 at 01:20
  • Probably replaced by as_array('id', 'label') which returns an associative array of id => label which is perfect for handing off to a select list. – Gerry Shaw Oct 05 '10 at 18:29
  • This is annoying, the kohana docs are all over the place and the official docs only showed 'order_by' and no way to use.... – Shawn Mclean Dec 26 '11 at 02:18
  • order_by() in kohana 2.3, you have to put something like this in your model. protected $sorting = array('last_login' => 'desc', 'username' => 'asc'); – Alex Coroza Jun 27 '14 at 04:36