根据日期按顺序列出数据
我正在学习cakePHP 1.26。
我在表测试中获得了一些示例数据,其中包含两个字段:
(此示例表中没有主键)
数据|日期
你好 | 2010-07-1 15:11:11
世界 |2010-07-1 11:01:01
您好 | 2010-07-02 11:36:11
我需要根据写入数据库的日期找出他们的位置编号,
即哪一个先出现以及其中哪一个位居第二。
但我不知道cakePHP中是否有一个组件可以帮助我解决这个问题。
当数据库中只有几条记录时,根据日期手动列出它们并为每条记录编号是很容易的,但是当记录增长时,人类将很难这样做:
记录1 : 你好
记录2:你好
记录3:世界
I am learning cakePHP 1.26.
I got some sample data in a Table Testing which consists of two fields:
(there is not primary key in this sample Table)
Data | Date
Hello | 2010-07-1 15:11:11
World | 2010-07-1 11:01:01
Hi there | 2010-07-02 11:36:11
I need to find out their position number according to the Date when they were written into the Database,
i.e. which of them came first and which of them came second.
But I don't know if there is a component in cakePHP that can help me solve the question.
It is easy to list them out according to the Date and number each record manually when there are only a few records in the Database,but when the reocrds grow, it will be difficult for humans to do it this way:
Record 1: Hi there
Record 2: Hello
Record 3: World
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在控制器中
在模型中
In controller
In model