- STATIC ATTRIBUTES
- STATIC METHODS
SQL::Abstract::Query::Statement - A role providing base functionality for statement objects.
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.
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.
All of these type names are prefixed with "SQL::Abstract::Query::Types::".
The name of a table. Currently there are no restrictions on this type except that it must be a plain string.
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.
The where clause. Must be a hashref, arrayref, or a plain string.
The SQL::Abstract::Query object that was used to generate this particular query object.
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.
The bind values that were returned by the original construction of the abstract_result() attribute. Typically you will not need to access this directly.
my $sql = $statement->sql();
This read-only attribute returns the SQL that was generated for the query.
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.
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.
This is a shortcut to calling $query->abstract->_quote().
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.
Aran Clary Deltac <firstname.lastname@example.org>
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.