NAME
SQL::Object - Yet another SQL condition builder
SYNOPSIS
use SQL::Object qw/sql_obj/;
my $sql = sql_obj('foo.id=?',1);
$sql->as_sql; # 'foo.id=?'
$sql->bind; # qw/1/
$sql->and('foo.name=?','nekokak');
$sql->as_sql; # 'foo.id=? AND foo.name=?'
$sql->bind; # qw/1 nekokak/
$sql->as_sql; # 'foo.id=? AND foo.name=?'
my $other_cond = sql_obj('foo.id=?', 2);
$other_cond->and('foo.name=?','tokuhirom');
$other_cond->as_sql; # 'foo.id=? AND foo.name=?'
$sql = $sql | $other_cond; # $sql->compose_or($other_cond)
$sql->as_sql; # ('foo.id=? AND foo.name=?') OR ('foo.id=? AND foo.name=?')
$sql->bind; # qw/1 nekokak 2 tokuhirom/
$sql->add_parens;
$sql = $sql & sql('baz.name=?','lestrrat'); # $sql->compose_and(sql('baz.name=?','lestrrat'))
$sql->as_sql; # ((('foo.id=? AND foo.name=?') OR ('foo.id=? AND foo.name=?')) OR (foo.id IN (?,?))) AND baz.name=?
$sql = sql_obj('SELECT * FROM user WHERE ') + $sql;
$sql->as_sql; # SELECT * FROM user WHERE ((('foo.id=? AND foo.name=?') OR ('foo.id=? AND foo.name=?')) OR (foo.id IN (?,?))) AND baz.name=?
DESCRIPTION
SQL::Object is raw level SQL maker
METHODS
my $sql = sql($stmt, $bind)
create SQL::Object's instance.
my $sql_type = sql_type(\$val, SQL_VARCHAR)
create SQL::Object::Type's instance
my $sql = SQL::Object->new(sql => $sql, bind => \@bind);
create SQL::Object's instance
$sql = $sql->and($sql, @bind)
compose sql. operation 'ADN'.
$sql = $sql->or($sql, @bind)
compose sql. operation 'OR'.
$sql = $sql->compose_and(sql($sql, $bind))
compose sql object. operation 'AND'.
$sql = $sql->compose_or(sql($sql, $bind))
compose sql object. operation 'OR'.
$sql->add_parens()
bracket off current SQL.
$sql->as_sql()
get sql statement.
$sql->bind()
get sql bind variables.
SQL::Object::Type
SQL::Object:Type is SQL Types wrapper.
my $val = $sql_type->value()
return setting dereferenced value.
my $val_ref = $sql_type->value_ref()
return setting value reference.
my $sql_type = $sql_type->type()
return setting SQLType.
AUTHOR
Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.