Alzabo::SQLMaker - Alzabo base class for RDBMS drivers |
Alzabo::Table
and/or Alzabo::Column
objects)Alzabo::Table
)Alzabo::Table
object, ...)Alzabo::Table
object(s)
and/or $string(s))Alzabo::Column
object or SQL function), $comparison, (Alzabo::Column
object, $value, or Alzabo::SQLMaker
object), [ see below ] )where
)where
)Alzabo::Column
objects)Alzabo::Table
object, optional Alzabo::Column
objects)Alzabo::Column
object => $value, ...)Alzabo::Column
object => $value, ...)
Alzabo::SQLMaker - Alzabo base class for RDBMS drivers
use Alzabo::SQLMaker;
my $sql = Alzabo::SQLMaker->new( sql => 'MySQL' );
This is the base class for all Alzabo::SQLMaker modules. To
instantiate a driver call this class's new
method. See
SUBCLASSING Alzabo::SQLMaker for information on how to make a
driver for the RDBMS of your choice.
A list of names representing the available Alzabo::SQLMaker
subclasses. Any one of these names would be appropriate as a
parameter for the Alzabo::SQLMaker->new
method.
Load the specified subclass.
The name of the Alzabo::SQLMaker
subclass that was loaded.
This class can be used to generate SQL by calling methods that are the
same as those used in SQL (select
, update
, etc.) in sequence,
with the appropriate parameters.
There are four entry point methods, select
, insert
,
update
, and delete
.
Attempting call any other method without first calling one of these is
an error.
These methods are called as class methods and return a new object.
Alzabo::Table
and/or Alzabo::Column
objects)This begins a select. The columns to be selected are the column(s)
passed in, and/or the columns of the table(s)
passed in as arguments.
Alzabo::Table
)
All of these methods return the object itself, making it possible to chain together method calls such as:
Alzabo::SQLMaker->select($column)->from($table)->where($other_column, '>', 2);
Alzabo::Table
object, ...)The table(s)
from which we are selecting data.
Alzabo::Table
object(s)
and/or $string(s))There is no publically available method in this class called
** function
. This method represents all available SQL functions, such
as COUNT
or AVG
. The name of the method is the name of the
function to be called. Each subclass knows which functions are legal
for the RDBMS they represent. All the arguments are joined together
by commas (,) internally. Here is a simple example:
Alzabo::SQLMaker->select->count($column)->from($table)->where($other_column, '>', 2);
Alzabo::Column
object or SQL function), $comparison, (Alzabo::Column
object, $value, or Alzabo::SQLMaker
object), [ see below ] )The first parameter must be an Alzabo::Column
object or SQL
function. The second is a comparison operator of some sort, given as
a string. The third argument can be one of three things. It can be
an Alzabo::Column
object, a value (a number or string), or an
Alzabo::SQLMaker
object. The latter is treated as a subselect.
Values given as parameters will be properly quoted an escaped.
Some comparison operators allow additional parameters.
The BETWEEN
comparison operator requires a fourth argument. This
must be either an Alzabo::Column
object or a value.
The IN
operator allows any number of additional parameters, which
may be Alzabo::Column
objects, values, or Alzabo::SQLMaker
objects.
where
)
where
)These methods take the same parameters as the
where
method. There is currently no way
to group together comparison operators.
Alzabo::Column
objects)Adds an ORDER BY
clause to your SQL.
Modifies the sorting of an ORDER BY
clause.
Specifies a limit on the number of rows to be returned. The offset parameter is optional.
Nothing.
Alzabo::Table
object, optional Alzabo::Column
objects)Used to specify what table an insert is into. If column objects are
given then it is expected that values will only be given for that
object. Otherwise, it assumed that all columns will be specified in
the values
method.
Alzabo::Column
object => $value, ...)This method expects to recive an structured like a hash where the keys
are Alzabo::Column
objects and the values are the value to be
inserted into that column.
Nothing.
Alzabo::Column
object => $value, ...)This method'a parameter are exactly like those given to the
values
method.
This can be called at any time though obviously it will not return valid SQL unless called at a natural end point. In the future, an exception may be thrown if called when the SQL is not in a valid state.
The SQL generated so far.
An array reference containing the parameters to be bound to the SQL statement.
This method may return undef even if the
limit
method was
called. Some RDBMS's have special SQL syntax for LIMIT
clauses.
For those that don't support this, the
Alzabo::Driver in the Alzabo::Driver
manpage module takes a limit
parameter.
The return value of this method can be passed in as that parameter in
all cases.
If the RDBMS does not support LIMIT
clauses, the return value is an
array reference containing two values, the maximum number of rows
allowed and the row offset (the first row that should be used).
If the RDBMS does support LIMIT
clauses, then the return value is
undef
.
To create a subclass of Alzabo::SQLMaker
for your particular RDBMS
requires only that the Alzabo::SQLMaker/Virtual Methods in the virtual methods manpage listed below be implemented.
In addition, you may choose to override any of the other methods
listed in over-rideable methods. For
example, the MySQL subclass override the
_subselect
method because MySQL
cannot support sub-selects.
Dave Rolsky, <dave@urth.org>
Alzabo::SQLMaker - Alzabo base class for RDBMS drivers |