Open agborkowski opened 11 years ago
static function childrens($parent) { // $sql = "SELECT node.*, (COUNT(parent.name) - 1) AS depth "; // $sql .= "FROM ". self::meta('source') ." AS node, "; // $sql .= self::meta('source') . " AS parent "; // $sql .= "WHERE node.parent_id = " . $parent . " AND node.lft BETWEEN parent.lft AND parent.rght "; // $sql .= "GROUP BY node.name "; // $sql .= "ORDER BY node.lft;"; $sql = "SELECT node.*, (COUNT(parent.id) - (sub_tree.depth + 1)) AS depth "; $sql .= "FROM " . self::meta('source') . " AS node, "; $sql .= " " . self::meta('source') . " AS parent, "; $sql .= " " . self::meta('source') . " AS sub_parent, "; $sql .= " ( "; $sql .= " SELECT node.*, (COUNT(parent.id) - 1) AS depth "; $sql .= " FROM " . self::meta('source') . " AS node, "; $sql .= " " . self::meta('source') . " AS parent "; $sql .= " WHERE node.lft BETWEEN parent.lft AND parent.rght "; $sql .= " AND node.id = ". $parent . " "; $sql .= " GROUP BY node.name "; $sql .= " ORDER BY node.lft "; $sql .= " ) AS sub_tree "; $sql .= "WHERE node.lft BETWEEN parent.lft AND parent.rght "; $sql .= " AND node.lft BETWEEN sub_parent.lft AND sub_parent.rght "; $sql .= " AND sub_parent.id = sub_tree.id "; $sql .= "GROUP BY node.name "; $sql .= "ORDER BY node.lft; "; return static::connection()->read($sql); }
any idea to attach levels to childrens() behavior function ?
Tests passed on travis: https://travis-ci.org/jails/li3_tree May it be related to your lithium version ?
any idea to attach levels to childrens() behavior function ?