如果你知道我的桌子看起来像这些
[category]
-category_id
-lft
-rgt
....
[catinfo]
-catinfo_id
-category_id
-lang_id
-name
....
[lang]
-lang_id
-language
如何在 Kohana ORM 中重写此查询?
SELECT node.category_id, catinfo.name, COUNT("parent.category_id") - 1 AS depth
FROM category AS parent, category AS node
LEFT JOIN catinfo
ON catinfo.category_id = node.category_id
WHERE node.lft BETWEEN parent.lft AND parent.rgt
AND catinfo.lang_id = 1
GROUP BY node.category_id
HAVING depth <= 3
ORDER BY node.lft
我不知道如何开始。