gpt4 book ai didi

mysql - 使用 like 加入 code igniter 事件记录

转载 作者:行者123 更新时间:2023-11-29 02:05:45 28 4
gpt4 key购买 nike

我的事件记录查询中的特定点赞有问题。

当我使用 join('users parent', 'child.treePath LIKE CONCAT(parent.treePath,"%")')Code igniter 吐出 JOIN 'users' parent ON 'child'.'treePath' 'LIKE' CONCAT(parent.treePath,"%")(注意我已经替换了所有反引号( `) 和 (') 由于 markdown :/)

因此,问题在于代码点火器将 LIKE 包装在 (`) 中。

我如何告诉它尝试格式化这个 block ?


完整查询:

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

最佳答案

如果你在一次调用中将所有这些函数链接在一起,你还不如使用

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

在您的案例中没有看到使用 Codeigniter 的查询构建器的好处。

关于mysql - 使用 like 加入 code igniter 事件记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6351781/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com