The xPDOQuery extends the xPDOCriteria class and allows you to abstract out complex SQL queries into an OOP format. This allows encapsulation of SQL calls so that they can work in multiple database types, and be easy to read and dynamically build.

  1. xPDOQuery.andCondition
  2. xPDOQuery.groupby
  3. xPDOQuery.innerJoin
  4. xPDOQuery.leftJoin
  5. xPDOQuery.limit
  6. xPDOQuery.orCondition
  7. xPDOQuery.rightJoin
  8. xPDOQuery.select
  9. xPDOQuery.setClassAlias
  10. xPDOQuery.sortby
  11. xPDOQuery.where


Grab the first 4 Boxes with:

  1. Owners that have the letter 'a' in their names
  2. A width of at least 10
  3. A height that is not 2
  4. sorted by the Box name, ascending and then by the Box height, descending
$query = $xpdo->newQuery('Box');
// the Owner is actually a User object, defined as Owner in the relationship alias
    'Owner.name:LIKE' => '%a%',
    'Box.width:>=' => 10,
    'Box.height:!=' => 2,
$boxes = $xpdo->getCollection('Box',$query);

See Also

Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab) or become an editor of the MODX Documentation.