我怎么能得到所有的集合推进模型


How can I get all collections of Propel model?

如何遍历所有的Propel对象集合,例如:

foreach ($obj->getCollections() as $collectionName)
{
    echo "Object's collection $collectionName has " . count($obj->{"get".$collectionName}) . " items<br>'n";
}

可以使用TableMap::getRelations()函数。在这篇文章中,你可以找到关于Propel自省的所有信息:http://propelorm.org/cookbook/runtime-introspection.html

PS如果你只想知道相关对象的数量,不要去检索所有的记录-使用count()查询函数只返回计数。