本文整理汇总了PHP中Branch::order_by方法的典型用法代码示例。如果您正苦于以下问题:PHP Branch::order_by方法的具体用法?PHP Branch::order_by怎么用?PHP Branch::order_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch::order_by方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($offset = 0)
{
$this->filter_access('Branch', 'roled_select', base_url());
$branch_list = new Branch();
switch ($this->input->get('c')) {
case "1":
$data['col'] = "branch_name";
break;
case "2":
$data['col'] = "branch_id";
break;
default:
$data['col'] = "branch_id";
}
if ($this->input->get('d') == "1") {
$data['dir'] = "DESC";
} else {
$data['dir'] = "ASC";
}
$data['title'] = "Branch";
$data['btn_add'] = anchor('branches/add', 'Add New', "class='btn btn-primary'");
$data['btn_home'] = anchor(base_url(), 'Home', "class='btn btn-home'");
$uri_segment = 3;
$offset = $this->uri->segment($uri_segment);
if ($this->input->get('search_by')) {
$total_rows = $branch_list->like($_GET['search_by'], $_GET['q'])->count();
$branch_list->like($_GET['search_by'], $_GET['q'])->order_by($data['col'], $data['dir']);
} else {
$total_rows = $branch_list->count();
$branch_list->order_by($data['col'], $data['dir']);
}
$data['branch_list'] = $branch_list->get($this->limit, $offset)->all;
$config['base_url'] = site_url("branches/index");
$config['total_rows'] = $total_rows;
$config['per_page'] = $this->limit;
$config['uri_segment'] = $uri_segment;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->load->view('branches/index', $data);
}