我有一个问题,我的查询中的where子句不被尊重。这是我正在使用的查询:
Capsule::table('tblhosting')
->select('*','tbldomains.nextduedate as domainnextduedate' , 'tblhosting.nextduedate as hostingnextduedate')
->join('tblclients', 'tblhosting.userid', '=', 'tblclients.id')
->join('tbldomains', 'tblhosting.domain', '=', 'tbldomains.domain')
->where('tblhosting.nextduedate', '!=', 'tbldomains.nextduedate')
->where('tbldomains.status', '=', 'Active')
->where('tblhosting.termination_date', '=', '0000-00-00')
->get()
如果我做一个vardump,我得到这些值:
[56] => stdClass Object
(
[id] => 406
[userid] => 9
[orderid] => 730
[packageid] => 35
[server] => 9
[regdate] => 2016-12-23
[domain] => xxx.net
[paymentmethod] => banktransfer
[firstpaymentamount] => 0.00
[amount] => 0.00
[billingcycle] => Annually
[nextduedate] => 2017-12-23
[nextinvoicedate] => 2017-12-23
[termination_date] => 0000-00-00
[completed_date] => 0000-00-00
[domainstatus] => Active
[domainnextduedate] => 2017-12-23
[hostingnextduedate] => 2017-12-23
)
如您所见,tbldomains.nextduedate和tbldomains.nextduedate均为'2017-12-23',因此不应该返回它们,因为我使用了
->where('tblhosting.nextduedate', '!=', 'tbldomains.nextduedate')
我以为可能是因为我使用别名,但是当我尝试
->where('domainnextduedate', '!=', 'hostingnextduedate')
我收到一个PDO错误:
Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'domainnextduedate' in 'where clause''
我不确定我缺少什么。
谢谢!
最佳答案
您可以尝试以下代码:
->whereColumn('tblhosting.nextduedate', '!=', 'tbldomains.nextduedate')
关于php - 哪里不尊重条款?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42455359/