[英]Is it possible to make this query using CodeIgniter's Query Builder?
查询:
select (exists (select 1 from table1 where url = 'fajne-to-jest')) as in_table1,
(exists (select 1 from table2 where url = 'fajne-to-jest')) as in_table2;
我看不到功能存在。
我认为不可能,但也许我错了。
因此问题是,是否可以仅使用CodeIgniter的查询生成器来创建此复杂查询?
可能没有像您的示例那样优化。 最简单的解决方案是不使用Querybuilder并直接编写要在query()
使用的query()
。
$sql = "select (exists (select 1 from table1 where url = 'fajne-to-jest')) as in_table1,
(exists (select 1 from table2 where url = 'fajne-to-jest')) as in_table2";
$query = $this->db->query($sql);
Querybuilder(QB)是一个很棒的工具,但是它经常(也许比不是更多)是完全不必要的。 QB的主要任务是构建查询语句。 为什么要执行大量代码来创建易于编写的查询?
在需要有条件地更改查询语句的情况下,QB非常有用。 例如添加where子句,更改排序顺序等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.