viewable() ->merge_where($where) ->order_by("captured", "ASC") ->count_all(); } static function get_items($limit=null, $offset=null, $where=array()) { // Returns the items identified by $where, up to $limit, and starting at $offset. return ORM::factory("item") ->viewable() ->merge_where($where) ->order_by("captured", "ASC") ->find_all($limit, $offset); } static function get_position($item, $where=array()) { // Get's $item's position within $where. return ORM::factory("item") ->viewable() ->merge_where($where) ->where("items.id", "<=", $item->id) ->order_by("captured", "ASC") ->count_all(); } }