Retrieves a collection of xPDOObjects by the specified xPDOCriteria.
If none are found, returns an empty array.
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">
Get a collection of Box objects with a width of 40.
$boxes = $xpdo->getCollection('Box',array( 'width' => 40, ));
Often getCollection is used inside MODX Snippets, so you will call it via the $modx object and you will be fetching built-in MODX object collections, such as pages.
$pages = $modx->getCollection('modResource', array('template' => 3));
Remember that you need to call the collection by its object name. You may find it quite handy to keep open your
core/model/schema/modx.mysql.schema.xmlfile so you can review your object names, e.g. "modResource" for pages, or "modChunk" for chunks etc.
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).