New MidgardQueryBuilder features
Piotras demonstrated some new important features of Midgard 1.8 query builder.
With new query builder it is possible to create endless chains of dot separated joins.
<?php
// An example of new features of MidgardQueryBuilder
$qb = new MidgardQueryBuilder('midgard_topic');
// Limit to topics which use component 'net.nehmer.blog'
$qb->begin_group('AND');
$qb->add_constraint('parameter.domain', '=', 'midcom');
$qb->add_contraint('parameter.name', '=', 'component');
$qb->add_constraint('parameter.value', '=', 'net.nehmer.blog');
$qb->end_group();
// The topic has an attachment 'xml.gif'
$qb->add_constraint('attachment.name', '=', 'xml.gif');
// The topic was created before June 17th, 2006 - note that you can
// use different time formats (eg. 'YYYYMMDD', 'YYYY-MM-DD', etc)
$qb->add_constraint('metadata.created', '<', '2006-06-17');
// Name of the person who created is NOT 'piotras'
$qb->add_constraint('creator.username', '<>', 'piotras');
// When the owner of the topic was edited
$qb->add_constraint('owner.metadata.edited', '>', '20060614');
// Add order by lastname
$qb->add_order('owner.lastname');
$results = $qb->execute();
?>
All of the new features have been documented in Midgard Documentation wiki.