using like in join with code igniter active records

六月ゝ 毕业季﹏ 提交于 2019-12-10 11:13:57

问题


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');

回答1:


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.



来源:https://stackoverflow.com/questions/6351781/using-like-in-join-with-code-igniter-active-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!