gpt4 book ai didi

sql - 如何将 GREATER_THAN/LESS_THAN 运算符添加到 Zend\Db\Sql 中的数据库查询?

转载 作者:搜寻专家 更新时间:2023-10-30 19:41:31 26 4
gpt4 key购买 nike

我需要在查询中添加特殊运算符。查询:

SELECT "contests".*
FROM "contests" WHERE "status" = '-1'
AND "level1" = '1' AND "level2" = '1' AND "level3" = '1' AND "level10" = '1'
AND DATE(`contests`.`start`) >= '2012-03-17' AND DATE(`contests`.`stop`) <= '2013-12-20'

在 Zend Framework 2 中:

$from = '2012-03-17';
$to = '2013-12-20';
$sql = new Sql($this->adapter);
$select = $sql->select('contests')
->where($where, $combination = new Predicate\Operator($from, Predicate\Operator::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $to));

但这行不通。

最佳答案

如果你这样写你的 where 子句会怎么样:-

$select->where->equalTo('status', '-1'); 
$select->where->equalTo('level1', '1');

等等

$select->where->greaterThanOrEqualTo('start', '2012-03-17');
$select->where->greaterThanOrEqualTo('stop', '2013-12-20');

关于sql - 如何将 GREATER_THAN/LESS_THAN 运算符添加到 Zend\Db\Sql 中的数据库查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20571974/

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