作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从我的表中选择两个 Unix 日期之间的用户。我不知道我做错了什么,但它会引发错误。我也在使用 Yii 框架。
我的想法是选择过去 30 分钟内创建的用户,直到当前时间为止。
这就是我正在做的。
public function actionIndex() {
$model = Cotizacion::find();
->where(['created_at' BETWEEN time() - (30 * 60) AND time()])
->all();
$this->layout = false;
return $this->render('index', ['actionIndex' => $model]);
}
列名是“created_at”。我见过类似的问题,但这些问题的答案都没有奏效。我将不胜感激任何帮助。对不起我的英语。
最佳答案
您在 where 子句中的引号已关闭。尝试将它们更改为:
->where(["'created_at' BETWEEN ".time()." - (30 * 60) AND ". time()])
关于php - SQL/PHP - Between Query with time() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37399080/
我是一名优秀的程序员,十分优秀!