Skip to content

Commit

Permalink
ORM::orderby -> ORM::order_by
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Nov 26, 2009
1 parent 0ef6994 commit 0121bfd
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion modules/comment/controllers/admin_comments.php
Expand Up @@ -48,7 +48,7 @@ public function queue($state) {
$view->content->menu = $this->_menu($view->content->counts);
$view->content->state = $state;
$view->content->comments = ORM::factory("comment")
->orderby("created", "DESC")
->order_by("created", "DESC")
->where("state", $state)
->limit(self::$items_per_page, ($page - 1) * self::$items_per_page)
->find_all();
Expand Down
2 changes: 1 addition & 1 deletion modules/comment/helpers/comment_block.php
Expand Up @@ -30,7 +30,7 @@ static function get($block_id) {
$block->title = t("Recent comments");
$block->content = new View("admin_block_recent_comments.html");
$block->content->comments =
ORM::factory("comment")->orderby("created", "DESC")->limit(5)->find_all();
ORM::factory("comment")->order_by("created", "DESC")->limit(5)->find_all();
break;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/comment/helpers/comment_rss.php
Expand Up @@ -36,7 +36,7 @@ static function feed($feed_id, $offset, $limit, $id) {
$comments = ORM::factory("comment")
->viewable()
->where("state", "published")
->orderby("created", "DESC");
->order_by("created", "DESC");

if ($feed_id == "item") {
$comments->where("item_id", $id);
Expand Down
2 changes: 1 addition & 1 deletion modules/comment/helpers/comment_theme.php
Expand Up @@ -39,7 +39,7 @@ static function photo_bottom($theme) {
$view->comments = ORM::factory("comment")
->where("item_id", $theme->item()->id)
->where("state", "published")
->orderby("created", "ASC")
->order_by("created", "ASC")
->find_all();

$block->content = $view;
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/controllers/admin_advanced_settings.php
Expand Up @@ -22,7 +22,7 @@ public function index() {
$view = new Admin_View("admin.html");
$view->content = new View("admin_advanced_settings.html");
$view->content->vars = ORM::factory("var")
->orderby("module_name", "name")
->order_by("module_name", "name")
->find_all();
print $view;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/gallery/controllers/admin_maintenance.php
Expand Up @@ -41,9 +41,9 @@ public function index() {
$view->content = new View("admin_maintenance.html");
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")
->where("done", 0)->orderby("updated", "DESC")->find_all();
->where("done", 0)->order_by("updated", "DESC")->find_all();
$view->content->finished_tasks = ORM::factory("task")
->where("done", 1)->orderby("updated", "DESC")->find_all();
->where("done", 1)->order_by("updated", "DESC")->find_all();
print $view;
}

Expand Down
10 changes: 5 additions & 5 deletions modules/gallery/helpers/access.php
Expand Up @@ -171,7 +171,7 @@ static function locked_by($group, $perm_name, $item) {
->where("items.id <> $item->id")
->join("access_intents", "items.id", "access_intents.item_id")
->where("access_intents.view_$group->id", self::DENY)
->orderby("level", "DESC")
->order_by("level", "DESC")
->limit(1)
->find();

Expand Down Expand Up @@ -494,7 +494,7 @@ private static function _update_access_view_cache($group, $item) {
->where("right_ptr >", $item->right_ptr)
->join("access_intents", "access_intents.item_id", "items.id")
->where("access_intents.$field", self::DENY)
->orderby("left_ptr", "DESC")
->order_by("left_ptr", "DESC")
->limit(1)
->find();
if ($tmp_item->loaded()) {
Expand All @@ -516,7 +516,7 @@ private static function _update_access_view_cache($group, $item) {
->where("right_ptr <=", $item->right_ptr)
->where("type", "album")
->where("access_intents.$field IS NOT", self::INHERIT)
->orderby("level", "DESC")
->order_by("level", "DESC")
->find_all();
foreach ($query as $row) {
if ($row->$field == self::ALLOW) {
Expand Down Expand Up @@ -565,7 +565,7 @@ private static function _update_access_non_view_cache($group, $perm_name, $item)
->where("left_ptr <", $item->left_ptr)
->where("right_ptr >", $item->right_ptr)
->where("$field IS NOT", self::UNKNOWN)
->orderby("left_ptr", "DESC")
->order_by("left_ptr", "DESC")
->limit(1)
->find();
if ($tmp_item->loaded()) {
Expand All @@ -581,7 +581,7 @@ private static function _update_access_non_view_cache($group, $perm_name, $item)
->where("left_ptr >=", $item->left_ptr)
->where("right_ptr <=", $item->right_ptr)
->where("$field IS NOT", self::INHERIT)
->orderby("level", "ASC")
->order_by("level", "ASC")
->find_all();
foreach ($query as $row) {
$value = ($row->$field === self::ALLOW) ? "TRUE" : "FALSE";
Expand Down
4 changes: 2 additions & 2 deletions modules/gallery/helpers/gallery_block.php
Expand Up @@ -46,15 +46,15 @@ static function get($block_id) {
$block->title = t("Photo stream");
$block->content = new View("admin_block_photo_stream.html");
$block->content->photos =
ORM::factory("item")->where("type", "photo")->orderby("created", "DESC")->find_all(10);
ORM::factory("item")->where("type", "photo")->order_by("created", "DESC")->find_all(10);
break;

case "log_entries":
$block->css_id = "g-log-entries";
$block->title = t("Log entries");
$block->content = new View("admin_block_log_entries.html");
$block->content->entries = ORM::factory("log")
->orderby(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5);
->order_by(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5);
break;

case "stats":
Expand Down
4 changes: 2 additions & 2 deletions modules/gallery/helpers/gallery_rss.php
Expand Up @@ -30,13 +30,13 @@ static function feed($feed_id, $offset, $limit, $id) {
$feed->children = ORM::factory("item")
->viewable()
->where("type !=", "album")
->orderby("created", "DESC")
->order_by("created", "DESC")
->find_all($limit, $offset);

$all_children = ORM::factory("item")
->viewable()
->where("type !=", "album")
->orderby("created", "DESC");
->order_by("created", "DESC");

$feed->max_pages = ceil($all_children->find_all()->count() / $limit);
$feed->title = t("Recent updates");
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/helpers/graphics.php
Expand Up @@ -183,7 +183,7 @@ private static function _get_rules($target) {
foreach (ORM::factory("graphics_rule")
->where("target", $target)
->where("active", true)
->orderby("priority", "asc")
->order_by("priority", "asc")
->find_all() as $rule) {
$rules[] = (object)$rule->as_array();
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/helpers/item.php
Expand Up @@ -142,7 +142,7 @@ static function get_max_weight() {
// @todo: figure out a better way to bootstrap the weight.
$result = Database::instance()
->select("weight")->from("items")
->orderby("weight", "desc")->limit(1)
->order_by("weight", "desc")->limit(1)
->get()->current();
return ($result ? $result->weight : 0) + 1;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/helpers/module.php
Expand Up @@ -364,7 +364,7 @@ static function get_var($module_name, $name, $default_value=null) {
foreach (Database::instance()
->select("module_name", "name", "value")
->from("vars")
->orderby("module_name", "name")
->order_by("module_name", "name")
->get() as $row) {
if ($row->module_name == "gallery" && $row->name == "_cache") {
// This could happen if there's a race condition
Expand Down
32 changes: 16 additions & 16 deletions modules/gallery/models/item.php
Expand Up @@ -291,7 +291,7 @@ private function _build_relative_caches() {
->where("left_ptr <=", $this->left_ptr)
->where("right_ptr >=", $this->right_ptr)
->where("id <>", 1)
->orderby("left_ptr", "ASC")
->order_by("left_ptr", "ASC")
->get() as $row) {
// Don't encode the names segment
$names[] = rawurlencode($row->name);
Expand Down Expand Up @@ -460,7 +460,7 @@ public function get_position($child, $where=array()) {
->where("parent_id", $this->id)
->where($sort_column, $child->$sort_column)
->where($where)
->orderby(array("id" => "ASC"))
->order_by(array("id" => "ASC"))
->get() as $row) {
$position++;
if ($row->id == $child->id) {
Expand All @@ -475,18 +475,18 @@ public function get_position($child, $where=array()) {
//
// Reproduce the children() functionality here using Database directly to avoid loading the
// whole ORM for each row.
$orderby = array($this->sort_column => $this->sort_order);
$order_by = array($this->sort_column => $this->sort_order);
// Use id as a tie breaker
if ($this->sort_column != "id") {
$orderby["id"] = "ASC";
$order_by["id"] = "ASC";
}

$position = 0;
foreach ($db->select("id")
->from("items")
->where("parent_id", $this->id)
->where($where)
->orderby($orderby)
->order_by($order_by)
->get() as $row) {
$position++;
if ($row->id == $child->id) {
Expand Down Expand Up @@ -592,18 +592,18 @@ public function movie_img($extra_attrs) {
* @param integer SQL limit
* @param integer SQL offset
* @param array additional where clauses
* @param array orderby
* @param array order_by
* @return array ORM
*/
function children($limit=null, $offset=0, $where=array(), $orderby=null) {
if (empty($orderby)) {
$orderby = array($this->sort_column => $this->sort_order);
function children($limit=null, $offset=0, $where=array(), $order_by=null) {
if (empty($order_by)) {
$order_by = array($this->sort_column => $this->sort_order);
// Use id as a tie breaker
if ($this->sort_column != "id") {
$orderby["id"] = "ASC";
$order_by["id"] = "ASC";
}
}
return parent::children($limit, $offset, $where, $orderby);
return parent::children($limit, $offset, $where, $order_by);
}

/**
Expand All @@ -617,14 +617,14 @@ function children($limit=null, $offset=0, $where=array(), $orderby=null) {
* @param array additional where clauses
* @return object ORM_Iterator
*/
function descendants($limit=null, $offset=0, $where=array(), $orderby=null) {
if (empty($orderby)) {
$orderby = array($this->sort_column => $this->sort_order);
function descendants($limit=null, $offset=0, $where=array(), $order_by=null) {
if (empty($order_by)) {
$order_by = array($this->sort_column => $this->sort_order);
// Use id as a tie breaker
if ($this->sort_column != "id") {
$orderby["id"] = "ASC";
$order_by["id"] = "ASC";
}
}
return parent::descendants($limit, $offset, $where, $orderby);
return parent::descendants($limit, $offset, $where, $order_by);
}
}
2 changes: 1 addition & 1 deletion modules/server_add/controllers/server_add.php
Expand Up @@ -199,7 +199,7 @@ static function add($task) {
$entries = ORM::factory("server_add_file")
->where("task_id", $task->id)
->where("item_id", null)
->orderby("id", "ASC")
->order_by("id", "ASC")
->limit(10)
->find_all();
if ($entries->count() == 0) {
Expand Down
2 changes: 1 addition & 1 deletion modules/tag/controllers/admin_tags.php
Expand Up @@ -29,7 +29,7 @@ public function index() {
if ($filter) {
$query->like("name", $filter);
}
$view->content->tags = $query->orderby("name", "ASC")->find_all();
$view->content->tags = $query->order_by("name", "ASC")->find_all();
print $view;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/tag/controllers/tags.php
Expand Up @@ -84,7 +84,7 @@ public function autocomplete() {
$tag_part = end($tag_parts);
$tag_list = ORM::factory("tag")
->like("name", "{$tag_part}%", false)
->orderby("name", "ASC")
->order_by("name", "ASC")
->limit($limit)
->find_all();
foreach ($tag_list as $tag) {
Expand Down
4 changes: 2 additions & 2 deletions modules/user/controllers/admin_users.php
Expand Up @@ -22,10 +22,10 @@ public function index() {
$view = new Admin_View("admin.html");
$view->content = new View("admin_users.html");
$view->content->users = ORM::factory("user")
->orderby("name", "ASC")
->order_by("name", "ASC")
->find_all();
$view->content->groups = ORM::factory("group")
->orderby("name", "ASC")
->order_by("name", "ASC")
->find_all();
print $view;
}
Expand Down

0 comments on commit 0121bfd

Please sign in to comment.