【发布时间】:2010-05-11 09:51:42
【问题描述】:
symfony 有没有办法从一个学说嵌套集合中获取从 id 元素指定的整个路径/路线到 Doctrine_Collection 或数组中的根元素?
【问题讨论】:
标签: php symfony1 doctrine nested-sets
symfony 有没有办法从一个学说嵌套集合中获取从 id 元素指定的整个路径/路线到 Doctrine_Collection 或数组中的根元素?
【问题讨论】:
标签: php symfony1 doctrine nested-sets
【讨论】:
如果您正在考虑构建类似面包屑路径的东西,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”等的列来猜测要写什么。
【讨论】: