Phalcon不接受CASE查询

时间:2016-02-17 07:02:28

标签: php sql phalcon

我正在尝试使用case语句在phalcon中执行原始查询。当我尝试直接运行相同的查询时,我得到了结果但是当我使用phalcon查询模型时获得以下异常。它不接受WHEN声明。

查询:SELECT COUNT()AS COUNT,COLUMN4,COLUMN2,COLUMN5,案例当DATEDIFF(NOW(),TIME)< = 90那么0 ELSE 1 END作为TIME1从newjs.TABLENAME WHERE WHERE COLUMN1 =:VALUE: AND COLUMN2 IN({TYPE:array})AND COLUMN2 NOT IN({skip:array})GROUP BY COLUMN4,COLUMN2,COLUMN5,TIME1

  

异常'Phalcon \ Mvc \ Model \ Exception',带有消息'语法错误,   意外的标记WHEN,靠近'DATEDIFF(NOW(),TIME)< = 90那么   0 ELSE 1 END TIME1 FROM newjs.TABLENAME WHERE COLUMN1 =:VALUE:AND   COLUMN2 IN({TYPE:array})AND COLUMN2 NOT IN({skip:array})GROUP BY   COLUMN4,COLUMN2,COLUMN5,TIME1',解析时:SELECT COUNT()AS   COUNT,COLUMN4,COLUMN2,COLUMN5,案例DATEDIFF(NOW(),TIME)   < = 90那么0 ELSE 1结束从newjs.TABLENAME WHERE WHERE的TIME1   COLUMN1 =:VALUE:AND COLUMN2 IN({TYPE:array})AND COLUMN2 NOT IN   ({skip:array})GROUP BY COLUMN4,COLUMN2,COLUMN5,TIME1(256)'in   /Users/Pankaj1/Sites/branch/contactengine/models/Contacts.php:488\nStack   trace:\ n#0 [内部函数]:   Phalcon \ Mvc \ Model \ Query-> parse()\ n#1 [内部函数]:   多尔康\的mvc \模型\查询 - >执行()\ N#2   /Users/Pankaj1/Sites/branch/contactengine/models/Contacts.php(488):   Phalcon \ Mvc \ Model \ Manager-> executeQuery('SELECT COUNT()...',   阵列)\ N#3   /Users/Pankaj1/Sites/branch/contactengine/controllers/ContactController.php(532):   PhalconRest \ Models \ Contacts-> executeRawQuery('SELECT COUNT(*)...',   数组)\ n#4 [内部函数]:   PhalconRest \控制器\ ContactController-> getContactsCount( '9397643')\ N#5   [内部功能]:   尔康\的mvc \微\ LazyLoader-> __通话( 'getContactsCoun ......',   数组)\ n#6 [内部函数]:   多尔康\的mvc \微\ LazyLoader-> getContactsCount( '9397643')\ N#7   /Users/Pankaj1/Sites/branch/contactengine/index.php(307):   Phalcon \ Mvc \ Micro-> handle()\ n#8 {main}

请建议如何执行具有CASE语句的查询。

我甚至尝试使用查询构建。这也给了我同样的例外。

编辑: 我确实尝试过使用If语句,但这是有效的。还是想知道case语句是否适用于phalcon?

0 个答案:

没有答案