Order results from Kohana ORM
Asked Answered
B

1

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?
Bascio answered 5/10, 2010 at 1:0 Comment(0)
E
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

Emarie answered 5/10, 2010 at 1:15 Comment(5)
a function that must have existed an one point, but doesn't now. saw it in these docs: docs.kohanaphp.com/libraries/ormBascio
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.Emarie
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.Truncheon
This is annoying, the kohana docs are all over the place and the official docs only showed 'order_by' and no way to use....Maebashi
order_by() in kohana 2.3, you have to put something like this in your model. protected $sorting = array('last_login' => 'desc', 'username' => 'asc');Scoville

© 2022 - 2024 — McMap. All rights reserved.