首页 \ 问答 \ Yii Query Builder多个where子句(Yii Query Builder multiple where clauses)

Yii Query Builder多个where子句(Yii Query Builder multiple where clauses)

我在堆栈中注意到我的查询没有正确执行,因为我在querybuilder中有多个where子句。 所以我在Yii Query构建器中查看了这个帖子Multiple call where

应用我读过的内容,但查询仍然没有结合where语句。 我究竟做错了什么?

            $command = Yii::app()->db->createCommand()
        ....
        ->where(array('in', 'u.id', $licenses), array('and', 'i.date_added > DATE_SUB(u.date_expired, INTERVAL  30 DAY)'));
        //->where(array('and', 'i.date_added > DATE_SUB(u.date_expired, INTERVAL  30 DAY)'));
        //->where(array('and', 'u.date_expired > CURDATE()'))
        ->group('u.id');

这些是3个单独的陈述,但我在阅读时将它们合并,但结果仍然相同。 只有1个where子句。


I noticed in my stack that my query wasn't being executed correctly as I had multiple where clauses in my querybuilder. So I looked at this post Multiple call where in Yii Query builder

Applied what i'd read, but still the query doesn't combine the where statements. What am I doing wrong?

            $command = Yii::app()->db->createCommand()
        ....
        ->where(array('in', 'u.id', $licenses), array('and', 'i.date_added > DATE_SUB(u.date_expired, INTERVAL  30 DAY)'));
        //->where(array('and', 'i.date_added > DATE_SUB(u.date_expired, INTERVAL  30 DAY)'));
        //->where(array('and', 'u.date_expired > CURDATE()'))
        ->group('u.id');

These were 3 individual statements, but I combined them as I read, but still the same result. Only 1 where clause.


原文:https://stackoverflow.com/questions/18668553
更新时间:2023-11-11 07:11

最满意答案

我遇到了同样的问题,是由EditorConfig for VS Code插件引起的。 尝试禁用此插件。 如果这不起作用,也许其他一些插件是罪魁祸首。


I had the same problem and was caused by EditorConfig for VS Code plugin. Try disabling this plugin. If that doesn't work, maybe some other plugin is the culprit.

相关问答

更多
  • crossPaths设置为true以启用/禁用交叉构建 (默认情况下为true)。 从sbt 0.13.8开始,你会发现默认情况下sbt为每个Scala版本处理源代码目录,从而消除每个项目自身的重复。 因此,如果您有多个Scala版本,您可以在源代码目录中放置特定于版本的代码。 但我同意这很让人困惑:如果你没有多个crossScalaVersions那么就不需要scala和scala-2.11 。 大部分的代码应该总是以scala ,如果你有多个Scala版本, 而且你有特定版本的代码,那么可以使用scal ...
  • 我建议你完全按照你所显示的方式做,因为它是最直接的一个。 初始化为-1 ,它将始终工作,独立于实际符号表示,而~有时会产生令人惊讶的行为,因为您必须具有正确的操作数类型。 只有这样,您将获得最高值的unsigned类型。 举一个可能的惊喜的例子,考虑一下: unsigned long a = ~0u; 它不一定将所有位1的模式存储到a 。 但是它将首先在unsigned int创建一个所有位1的模式,然后将其分配给a 。 当unsigned long有更多位时,会发生什么情况,并不是所有这些都是1。 并考 ...
  • 你可以做: for f in *.txt; do (cat "${f}"; echo) >> finalfile.txt; done 在运行上述命令之前,确保文件finalfile.txt不存在。 如果你被允许使用awk你可以做: awk 'FNR==1{print ""}1' *.txt > finalfile.txt You can do: for f in *.txt; do (cat "${f}"; echo) >> finalfile.txt; done Make sure the file ...
  • 如何使用filter_var ...: filter_var($required, FILTER_VALIDATE_BOOLEAN); 会给你: $required = 'false'; filter_var($required, FILTER_VALIDATE_BOOLEAN); // false $required = false; filter_var($required, FILTER_VALIDATE_BOOLEAN); // false $required = 'true'; filter ...
  • Visible是一个复杂的属性。 它没有设置和读取相同的内容。 如果将其设置为true或false则表示对象是否可见。 但是,当您阅读它时,它会显示该控件的可见性是设置为true还是false,但如果链中的任何父项也被隐藏,它将显示为false 。 因此设置和读取它是一回事:即使你将它设置为true ,当你读回它时,它也可能在调试器中变为false (再次,如果链中的任何父项被隐藏):它将变为true虽然父母是可见的。 但是,对于ToolStripItem ,请使用Available属性而不是Visible ...
  • 在你的两个循环中,你正在检查每一行和每一列。 你的逻辑表明,当一行或一列的总和等于第一行的总和(并且这包括第一行的总和!!!)时,你的变量isTrue变为真(永远)! 所以,你应该改变你的逻辑... 伪算法: isTrue = true int magicSum = sumOfFirstDiagonal if (magicSum != sumOfSecondDiagonal) {isTrue = false; return} for each row if (magicSum != sumOfRow ...
  • 我遇到了同样的问题,是由EditorConfig for VS Code插件引起的。 尝试禁用此插件。 如果这不起作用,也许其他一些插件是罪魁祸首。 I had the same problem and was caused by EditorConfig for VS Code plugin. Try disabling this plugin. If that doesn't work, maybe some other plugin is the culprit.
  • 它对存储没有任何意义。 根据其他可为空的列,如果此列偶尔会将可空的位图溢出到下一个字节,我们最多只会讨论一个字节,但很可能根本不会添加任何存储。 对于性能(以及程序员的生产力/维护),这取决于你打算如何使用它。 这里没有足够的信息,如果没有邀请任何实际将这个问题读到您的所有项目会议上的人,也不可能获得足够的信息。 就我个人而言,当我有一个默认为false的布尔列(然而你选择代表它),然后在某一点变为真并保持真实时 ,我喜欢使用一个可为空的DateTime列来表示任何日期值为true,NULL表示为false ...
  • 我正在重新发布一个被其所有者删除的答案,因为我认为它给出了最好的解释。 我不知道为什么作者删除它,我认为这是正确的,我已经投票取消删除。 显然这种行为在Git中是硬编码的,并且不依赖于core.safecrlf(我已经测试了这个,即使我设置了git config core.safecrlf false ,混合文件也保持不变。 原始答案如下: Autocrlf 不会转换混合行结尾,因为git的源代码告诉: https://github.com/git/git/commit/a0ad53c18100226cb1 ...
  • Grunt允许您获取和设置任何配置属性。 把它放在grunt.initConfig下面: var files = grunt.config.get('concat.js.files').map(function(prop){ prop.nonull = true; return prop; }); grunt.config.set('concat.js.files',files); 另一种方法是创建对象,然后将其传递给initConfig: files = [ { ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)