Re: Following links in QB

Jukka Zitting <[email protected]>
Newsgroups gmane.comp.web.midgard.devel
Message-ID <[email protected]>
Hi,

Piotras wrote:
> 1. How it affects ML objects?

No changes.

> 2. What about limit or group?

Limit works just as it does now. The limits set on the subordinate query 
builders will just be ignored, but the main query builder limits work 
just as before.

group?

> 3. How select will look like in such cases?

Simplified version (no ML, sitegroups, etc.):

     $qb = new MidgardQueryBuilder("midgard_article");
     $subqb = $qb->forward_join("author");
     $subqb->add_constraint("username", "=", "foo");
     $qb->execute();
     => SELECT a.* FROM article AS a, person AS b
        WHERE a.author = b.id AND b.username='foo'

     $qb = new MidgardQueryBuilder("midgard_person");
     $subqb = $qb->backward_join("midgard_member", "uid");
     $subqb->add_constraint("gid", "=", 123);
     $qb->execute();
     => SELECT a.* FROM person AS a
        WHERE (SELECT COUNT(*) FROM member AS b
               WHERE b.uid=a.id AND b.gid=123) > 0;
        (could also be implemented as a standard join)

     $qb = new MidgardQueryBuilder("midgard_person");
     $subqb = $qb->backward_join("midgard_member", "uid");
     $subsubqb => $subqb->forward_join("gid");
     $subsubqb->add_constraint("name", "LIKE", "% Corp.");
     $qb->execute();
     => SELECT a.* FROM person AS a
        WHERE (SELECT COUNT(*) FROM member AS b, grp AS c
               WHERE b.uid=a.id AND b.gid=c.id
               AND c.name LIKE '% Corp.') > 0;
        (could also be implemented as a standard join)

These are just general examples, the actual details are of course more 
complex.

BR,

Jukka Zitting
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.