The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SQL::Abstract::Query::Statement - A role providing base functionality for statement objects.

DESCRIPTION

This role contains the shared functionality for the various statement classes. Much of this module contains low-level pieces that the normal user will not need to access directly (and probably shouldn't).

The exceptions to this are the sql() attribute and the values() method, which should be used extensively by users of the query classes.

CONSTRUCTOR

    my $statement = SQL::Abstract::Query::SomeClass->new( %named_args );
    my $statement = SQL::Abstract::Query::SomeClass->new( $query, @arg_values );
    my $statement = SQL::Abstract::Query::SomeClass->new( $query, @arg_values, \%extra_args );

New statement objects may be created by passing arguments to new() as either named values (a hash or hashref of name/value pairs as is typical) or as positional values.

When passing arguments as positional values the first argument must be an instance of SQL::Abstract::Query. The rest of the arguments will be named using the "positional_args" static attribute which is declared by each statement class. A final hashref argument of extra arguments may be passed. All of the positional and extra arguments will be combined and used to instantiate the object.

TYPES

All of these type names are prefixed with "SQL::Abstract::Query::Types::".

Table

The name of a table. Currently there are no restrictions on this type except that it must be a plain string.

FieldValues

A hashref of name/value pairs where the names are column names and the values are the column values to be set. This type may also be passed as an arrayref which will be coerced and turned in to a hashref where the values equal the keys.

Where

The where clause. Must be a hashref, arrayref, or a plain string.

ARGUMENTS

query

The SQL::Abstract::Query object that was used to generate this particular query object.

ATTRIBUTES

abstract_result

This attribute contains the results of calling the underlying SQL::Abstract method plus any modifications that the query object makes. A query class must provide a builder method of the name _build_abstract_result() which is expected to return an array reference where the first entry is the SQL and the remaining entries are the bind values.

The SQL will provide the value for the sql() attribute and the bind values will provide the values for the original_values() attribute.

Typically you will have no need to access this attribute directly and instead should use the sql() attribute and the values() method.

original_values

The bind values that were returned by the original construction of the abstract_result() attribute. Typically you will not need to access this directly.

sql

    my $sql = $statement->sql();

This read-only attribute returns the SQL that was generated for the query.

STATIC ATTRIBUTES

positional_args

When "CONSTRUCTOR" is called with positional arguments, rather than named arguments, this attribute is used to determine which value should be assigned to which argument. Each statement class must provide a _build_positional_args() method that returns an arrayref of argument names.

METHODS

values

    my @bind_values = $statement->values( \%field_values );

Given a hash ref of field name/value pairs this will return the values in the order in which they appear in the SQL.

quote

This is a shortcut to calling $query->abstract->_quote().

STATIC METHODS

call

This method is called by SQL::Abstract::Query to provide the procedural interface to queries. Typically you will not want to call this directly.

All arguments are passed straight on to the "CONSTRUCTOR".

Returns a list containing the generated SQL and bind values.

AUTHOR

Aran Clary Deltac <bluefeet@gmail.com>

LICENSE

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.