0

我一直在尝试基于 Sazans 库实现多语言支持,但查询似乎对我不起作用。

库:https ://github.com/sazan/MultiLang-Library-for-PyroCMS/blob/master/README

我的错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM (`default_navigation_links`) WHERE `navigation_group_id` = '1' ORDER BY `p' at line 2

SELECT *, translate("navigation", `id`, `"title"`, `"en"`, `title)` AS title FROM (`default_navigation_links`) WHERE `navigation_group_id` = '1' ORDER BY `position`

该错误正在引发查询。我相信函数 translate 没有定义,这就是它抛出错误的原因。

The query: $this->db ->select('*, translate("navigation", id, "title", "'.CURRENT_LANGUAGE.'", title) AS title');

我尝试通过 phpmyadmin 在我的数据库上运行功能设置查询(在项目页面中找到)。当我添加它时 - 它没有返回错误,也没有“告诉我”它成功添加了函数。

知道我该怎么做吗?

4

1 回答 1

1

问题不在于函数,它与 CI 的 Active Record 类有关。CI AR 类会自动转义您使用$this->db ->select(...). 因此,要使用我存储的函数,您必须通过将 AR 的选择函数的第二个参数设置为 false 来关闭自动转义:

$this->db->select('*, translate("navigation", id, "title", "'.CURRENT_LANGUAGE.'", title) AS title', false);

它会起作用。干杯!

于 2012-03-30T22:05:57.697 回答