按降序排序表头,无需排序整个数据库表

编程入门 行业动态 更新时间:2024-10-14 14:21:09
本文介绍了按降序排序表头,无需排序整个数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道如何只在该页面中排序表头,而不排序整个table.is这可能在cakephp?请给我看一些示例代码。我的意见是

<?php echo $ url = $ this-> Paginator-> sort 'ID','id',array('direction'=>'desc')); $ arrow = getArrow($ url); ?> 这是我的控制器: $ this-> paginate = Set :: merge($ this-> paginate,array('OrderFinalized'=> array 'limit'=> 4,'conditions'=> $ condition_ary,'joins'=& ('table'=>'order_entry_headers','alias'=>'OrderEntryHeaders2','type'=>'inner','foreignKey' => false,'conditions'=> array('OrderEntryHeaders2.id = OrderFinalized.order_entry_headers_id'), 'order'=> array('OrderEntryHeaders2 .id'=>'desc')),

是查询:

$ result = $ this-> OrderEntryHeader-> query(SELECT(value + 1)as val FROM order_entries_seq ORDER BY OrderEntryHeader.id desc);

当我排序第一页的顺序,我得到最后的结果从数据库table.i想

exid_id名称(第1页)ASC 1 A 2 B 3 C 4 D

DESC ID名称 4 D 3 C 2 B 1 A

解决方案

你想要的是从数据库中检索数据,然后使用排序。最简单的方法是使用JavaScript。

您需要前端/客户端表格排序器,如

tablesorter/docs/#Demo

$ b

这是可能在CakePHP ,请在数组排序中a href =book.cakephp/2.0/en/models/callback-methods.html#afterfind =nofollow> afterFind方法

I would like to know how to sort a table header only in that page without sorting the whole table.is this possible in cakephp? please show me some sample code. my view is

<?php echo $url = $this->Paginator->sort('ID', 'id',array('direction' => 'desc')); $arrow = getArrow($url); ?> This is my Controller: $this->paginate = Set::merge($this->paginate, array('OrderFinalized' => array( 'limit'=>4, 'conditions' => $condition_ary, 'joins' => array( array( 'table' => 'order_entry_headers', 'alias' => 'OrderEntryHeaders2', 'type' => 'inner', 'foreignKey' => false, 'conditions' => array('OrderEntryHeaders2.id = OrderFinalized.order_entry_headers_id'), 'order' => array( 'OrderEntryHeaders2.id'=> 'desc' ) ),

this is the query:

$result = $this->OrderEntryHeader->query("SELECT (value+1) as val FROM order_entries_seq ORDER BY OrderEntryHeader.id desc ");

When I sort the first page desending order I get the last results from the database table.i want to sort only the results from that page.it should not change while navigation.

ex- id name (page 1) ASC 1 A 2 B 3 C 4 D

DESC id name 4 D 3 C 2 B 1 A

解决方案

What you want is to retrieve data from a database and then use the sorting. The easiest way is by using JavaScript.

You need front-end / client-side table sorter like

tablesorter/docs/#Demo

is it still possible to do with sort function?

It is possible in CakePHP, make array sort in afterFind method

更多推荐

按降序排序表头,无需排序整个数据库表

本文发布于:2023-10-18 15:00:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504568.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表头   数据库   降序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!