Synopsis
use SQL::QueryBuilder::OO;
$sql = sqlQueryBase::select(qw(id title description), {name => 'author'})
->from('article')
->innerJoin('users', 'userId') # -> INNER JOIN `users` USING(`userId`)
->leftJoin({'comments' => 'c'}, sqlCondition::EQ('userId', 'c.from')) # -> LEFT JOIN `comments` AS `c` ON(`userId` = `c`.`from`)
->where(sqlCondition::AND(
sqlCondition::EQ('category')->bind($cat),
sqlCondition::NE('hidden')->bind(1)))
->limit(10,20)
->groupBy('title')
->orderBy({'timestamp' => 'DESC'});
$dbh->do($sql, undef, $sql->gatherBoundArgs());
Description
This module provides for an object oriented way to create complex SQL queries while maintaining code readability. It supports conditions construction and bound query parameters.
The project is actually a port of PHP classes to construct queries used in one of my proprietary projects (which may explain the excessive use of the scope resolution operator (::) in the module’s sytax).
The 0.1 version's man-page can be reviewed on my blog. The tarball is available here.
Comments
Please sign up to post a review.