2010-05-11 37 views

回答

2

我想这应该返回你以后有什么:

$obj->getNode()->getAncestors(); 

docs

1

如果你想建立像一个导航条的,的getPath会做到这一点:

getPath 
public string getPath(string seperator, mixed includeRecord, bool includeNode) 

gets path to node from root, uses record::toString() method to get node names 

Parameters: 
    seperator - path seperator 
    includeNode - whether or not to include node at end of path 
Returns: 
    string representation of path 

http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_node_nestedset.html#getPath%28%29

所以你需要在你的模型中覆盖__toString()。如果你不这样做,Doctrine会尝试通过查找名为“name”,“title”等的列来猜测要写什么。