使用类似与code点火器的活动记录加盟 [英] using like in join with code igniter active records

查看:116
本文介绍了使用类似与code点火器的活动记录加盟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个特定的问题,如在我的活动记录的查询。

当我使用加入(用户父','child.treePath LIKE CONCAT(parent.treePath,%)') code点火吐出加入用户名家长'孩子'。TreePath的喜欢CONCAT(parent.treePath,%)(注意,我已经取代所有反引号(`)和()由于降价:/)

所以,问题是,code点火器被包裹像(`)。

我怎么能告诉它的不可以试图格式化这个块?


完整的查询:

  $这个 - > DB->选择(child.uuid)
          - >从('用户的孩子)
          - >加入(用户父','child.treePath LIKE CONCAT(parent.treePath,%)')
          - 化合物其中('parent.uuid',$ UUID)
          - 化合物其中(长度(REPLACE(child.treePath,parent.treePath,'')) - 长度(REPLACE(REPLACE(child.treePath,parent.treePath,''),'/',''))≤ =$的水平,假)
          - 化合物其中(长度(REPLACE(child.treePath,parent.treePath,'')) - 长度(REPLACE(REPLACE(child.treePath,parent.treePath,''),'/',''))&GT ;0,假)
          - > GROUP_BY('child.treeId');
 

解决方案

如果您要串联所有这些功能一起在一个单一的呼叫时,您可能也仅仅使用

  $这个 - > DB->查询(写入所有特定的SQL这里);
 

没有看到你的情况摔跤codeigniter的查询生成器的好处。

I am having issues with a particular like in my active records query.

When I use join('users parent', 'child.treePath LIKE CONCAT(parent.treePath,"%")') Code igniter spits out JOIN 'users' parent ON 'child'.'treePath' 'LIKE' CONCAT(parent.treePath,"%") (note that I have replaced all back ticks (`) with (') due to markdown :/)

So, the issue is that code igniter is wrapping LIKE in (`).

How can I tell it to not attempt to format this block?


Complete query:

$this->db->select('child.uuid')
         ->from('users child')
         ->join('users parent', 'child.treePath LIKE CONCAT(parent.treePath,"%")')
         ->where('parent.uuid', $uuid)
         ->where("LENGTH(REPLACE(child.treePath, parent.treePath, '')) - LENGTH(REPLACE(REPLACE(child.treePath, parent.treePath, ''), '/', '')) <= ",  $levels, 'false')
         ->where("LENGTH(REPLACE(child.treePath, parent.treePath, '')) - LENGTH(REPLACE(REPLACE(child.treePath, parent.treePath, ''), '/', '')) > ",  0, 'false')
         ->group_by('child.treeId');

解决方案

If you are chaining all these functions together in a single call, you might as well just use

$this->db->query("Write all your specific SQL here");

Not seeing the benefit of wrestling with Codeigniter's query builder in your case.

这篇关于使用类似与code点火器的活动记录加盟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆