gpt4 book ai didi

php - SQL/PHP - Between Query with time() 函数

转载 作者:行者123 更新时间:2023-11-28 23:30:49 25 4
gpt4 key购买 nike

我正在尝试从我的表中选择两个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com