【发布时间】:2014-05-21 12:59:37
【问题描述】:
这是SQL中的解决方案
SELECT *
FROM exploits
WHERE date
BETWEEN '2014-01-01'
AND '2014-12-31'
ORDER BY exploits.date DESC
LIMIT 0 , 30
这是我在 CakePhp 中的解决方案(在这方面完全是新手)
$exploits = $this->Exploit->find('all', array(
'conditions' => array(
'Exploit.date BETWEEN 2014-01-01 AND 2014-12-31')
$this->set('exploits', $exploits);
}
感谢您的帮助
======
尝试新代码时
错误:发生内部错误。
在此之前我所拥有的 `私有函数_index_action(){
$exploits = $this->Exploit->find('all', array(
'conditions' => array(
'is_published' => 1),
'limit' => 6,
'recursive' => -1,`
但我想尝试在日期之间仅显示 6 个元素...(抱歉 newbi 和法语:P)
【问题讨论】:
-
除了不使用限制或排序顺序之外 - 问题中的 find 调用会起作用(如果它是有效的 php 代码,而写它不是)。您可以对条件进行细微的更改,但结果有问题吗?如果是这样呢?
-
您遇到了什么错误或解释您的问题
-
您的编辑似乎与原始问题无关