2010-05-11 33 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」等的列來猜測要寫什麼。