How is it possible to write the following sql query with datamapper DMZ?
Code:
SELECT node.name, (COUNT(parent.name) - 1) AS depth
FROM $this->table AS node,
$this->table AS parent
WHERE node.$this->left_column BETWEEN parent.$this->left_column AND parent.$this->right_column
GROUP BY node.id
ORDER BY node.$this->left_column;
I'm particualry interested at the first 3 lines, where I select the same table AS alias.
Anyone has an idea?
The reason why I want to write this with DM is because I'm working on model extension which I'd like to make modular (without repeating the same sql code milion times accross diferent models that use Nested Sets)