NAME
DBIx::Skinny::SQL - dynamic SQL generator
SYNOPSIS
my $sql = DBIx::Skinny::SQL;
$sql->select(['foo', 'bar', 'baz']);
$sql->from(['table_name']);
$sql->as_sql;
#=> "SELECT foo, bar, baz FROM table_name;"
$sql->add_where('col' => "value");
$sql->as_sql;
#=> "SELECT foo, bar, baz FROM table_name WHERE ( col = ? );"
$sql->add_where(name => { like => "%value" });
$sql->as_sql;
#=> "SELECT foo, bar, baz FROM table_name WHERE ( col = ? ) AND ( name LIKE ? );"
$sql->add_where(bar => \"IS NOT NULL");
$sql->as_sql;
#=> "SELECT foo, bar, baz FROM table_name WHERE ( col = ? ) AND ( name LIKE ? ) AND ( bar IS NOT NULL );"
# execute SQL and return DBIx::Skinny::Iterator object.
my $iter = $sql->retrieve;
my $sql2 = DBIx::Skinny::SQL->new;
$sql2->from([]);
$sql2->add_join(foo => [
{ table => "bar", type => "inner", condition => "foo.bar_id = bar.id" },
]);
$sql2->select(['*']);
$sql2->as_sql;
#=> "SELECT * FROM foo INNER JOIN bar ON foo.bar_id = bar.id;"
$sql2->add_complex_where([[ -or => { foo => "bar" }, { foo => "baz" } ]]);
$sql2->as_sql;
#=> "SELECT * FROM foo INNER JOIN bar ON foo.bar_id = bar.id WHERE ( ( foo = ? ) OR ( foo = ? ) )"
DESCRIPTION
SEE ALSO
+<Data::ObjectDriver::SQL>