MODX Cloud

The Most Productive MODX Learning Playground Ever

Claim Free Lab Account

xPDO.getCollection

Skip to end of metadata
Go to start of metadata


xPDO::getCollection

Retrieves a collection of xPDOObjects by the specified xPDOCriteria.

If none are found, returns an empty array.

Syntax

API Docs: http://api.modxcms.com/xpdo/xPDO.html#getCollection

array getCollection (string $className, [xPDOCriteria|array|str|int $criteria = null], [bool|int $cacheFlag = true])

Remember, if you are using xPDO map and class files that were generated from XML schema, the classname is not the same as your table name. If in doubt, have a look at the schema XML file, e.g.

<object class="MyClassName" table="my_class_name" extends="xPDOObject">

Example

Get a collection of Box objects with a width of 40.

$boxes = $xpdo->getCollection('Box', array('width' => 40));

See Also

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.