<p>Are any of you aware of a library that helps you build/manipulate SQL queries, that supports JOIN's?</p>

<p>It would give a lot of flexibility i'd think if you have something where you could return an object, that has some query set, and still be able to apply JOIN's to it, subqueries and such.</p>

<p>I've search around, and have only found SQL Builder, which seems very basic, and doesn't support joins. Which would be a major feature that would really make it useful.</p>

Maybe you can try an
ORM
, like
Propel
or
Doctrine
, they have a nice programmatic query language, and they return you arrays of objects that represent rows in your database...
For example with Doctrine you can do joins like this:
```
```
$q = Doctrine_Query::create();
$q->from('User u')
->leftJoin('u.Group g')
->innerJoin('u.Phonenumber p WITH u.id > 3')
->leftJoin('u.Email e');

$users = $q->execute();
```
```
And with Propel:
```
```
$c = new Criteria(AuthorPeer::DATABASE_NAME);

$c->addJoin(AuthorPeer::ID, BookPeer::AUTHOR_ID, Criteria::INNER_JOIN);
$c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::INNER_JOIN);
$c->add(PublisherPeer::NAME, 'Some Name');

$authors = AuthorPeer::doSelect($c);
```
```
and you can do a lot more with both...