man Alzabo::SQLMaker () - Alzabo base class for RDBMS drivers


Alzabo::SQLMaker - Alzabo base class for RDBMS drivers


  use Alzabo::SQLMaker::MySQL;

  my $sql = Alzabo::SQLMaker::MySQL->new( driver => $driver_object );

  # or better yet

  my $sql = $runtime_schema->sqlmaker;


This is the base class for all Alzabo::SQLMaker modules. To instantiate a driver call this class's CWnew method. See SUBCLASSING Alzabo::SQLMaker for information on how to make a driver for the RDBMS of your choice.



Returns A list of names representing the available CWAlzabo::SQLMaker subclasses. Any one of these names would be appropriate as a parameter for the CWAlzabo::SQLMaker->load() method.


Load the specified subclass.

This takes one parameter, the name of the RDBMS being used.

Throws: CWAlzabo::Exception::Eval


This takes two parameters:

* driver
The driver object being used by the schema.
* quote_identifiers
A boolean value indicating whether or not identifiers should be quoted. This defaults to false.


This class can be used to generate SQL by calling methods that are the same as those used in SQL (CWselect(), CWupdate(), etc.) in sequence, with the appropriate parameters.

There are four entry point methods, CWselect(), CWinsert(), CWupdate(), and CWdelete(). Attempting to call any other method without first calling one of these is an error.

Entry Points

These methods are called as class methods and return a new object. 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.

Followed by: CWfrom() CW** function


Followed by: CWinto() Followed by: CWset()


Followed by: CWfrom()

Other Methods

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);
The table(s) from which we are selecting data.

Follows: CWselect() CW** function CWdelete()

Followed by: CWwhere()"> CWorder_by()

Throws: CWAlzabo::Exception::SQL

where <see below>

The first parameter to where must be an CWAlzabo::Column object or SQL function. The second is a comparison operator of some sort, given as a string. The third argument can be an CWAlzabo::Column object, a value (a number or string), or an CWAlzabo::SQLMaker object. The latter is treated as a subselect.

Values given as parameters will be properly quoted and escaped.

Some comparison operators allow additional parameters.

The CWBETWEEN comparison operator requires a fourth argument. This must be either an CWAlzabo::Column object or a value.

The CWIN and <NOT IN> operators allow any number of additional parameters, which may be CWAlzabo::Column objects, values, or CWAlzabo::SQLMaker objects.

Follows: CWfrom()

Followed by: CWand() CWor() CWorder_by()

Throws: CWAlzabo::Exception::SQL These methods take the same parameters as the CWwhere()"> method.

Follows: CWwhere()"> CWand() CWor()

Followed by: CWand() CWor() CWorder_by()

Throws: CWAlzabo::Exception::SQL Adds an CWORDER BY clause to your SQL.

Follows: CWfrom() CWwhere()"> CWand() CWor()

Followed by: CWlimit()

Throws: CWAlzabo::Exception::SQL Specifies a limit on the number of rows to be returned. The offset parameter is optional.

Follows: CWfrom() CWwhere()"> CWand() CWor() CWorder_by() CWAlzabo::Exception::SQL 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 CWvalues() method.

Follows: CWinsert()

Followed by: CWvalues()

Throws: CWAlzabo::Exception::SQL This method expects to recive an structured like a hash where the keys are CWAlzabo::Column objects and the values are the value to be inserted into that column.

Follows: CWinto()

Throws: CWAlzabo::Exception::SQL This method'a parameter are exactly like those given to the CWvalues method.

Follows: CWupdate()

Followed by: CWwhere()">

Throws: CWAlzabo::Exception::SQL



This method 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.

Returns the SQL generated so far as a string.


Returns an array reference containing the parameters to be bound to the SQL statement.


To create a subclass of CWAlzabo::SQLMaker for your particular RDBMS requires only that the virtual methods listed below be implemented.

In addition, you may choose to override any of the other methods described in this documentation. For example, the MySQL subclass override the CW_subselect() method because MySQL cannot support sub-selects.

Subclasses are also expected to offer for export various sets of functions matching SQL functions. See the CWAlzabo::SQLMaker::MySQL subclass implementation for details.


The following methods must be implemented by the subclass:


See above for the definition of this method.


This method may return CWundef even if the CWlimit() method was called. Some RDBMS's have special SQL syntax for CWLIMIT clauses. For those that don't support this, the CWAlzabo::Driver module takes a limit parameter.

The return value of this method can be passed in as that parameter.

If the RDBMS does not support CWLIMIT 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 CWLIMIT clauses, then the return value is CWundef.


Returns the subclass's name. This should be something that can be passed to CWAlzabo::SQLMaker->load() as a parameter.


Dave Rolsky, <>