NAME
DB::Object::Query::Elements - Query Elements Manipulation Class
SYNOPSIS
use DB::Object::Query::Elements;
my $elems = DB::Object::Query::Elements->new( debug => 4 ) ||
die( DB::Object::Query::Elements->error, "\n" );
$elems->push( $new_element );
$elems->push({
field => $some_field_name,
value => $some_field_value,
type => $sql_type,
format => $insert_formatting,
# Could also be $1, $2, ?1, ?2, or other variants supported by driver
placeholder => '?',
});
$elems->merge( $other_elements_object );
# Clause class inherits from Elements class
$elems->merge( $some_clause_object );
VERSION
v0.1.0
DESCRIPTION
This class represent a query manipulation class designed to access, store and retrieve query elements
Elements are stored in an internal array object accessible with "elements", and all the other methods are used to access or manipulate those elements data.
CONSTRUCTOR
new
Takes an hash or hash reference of key-value pairs matching any of the methods below.
Returns a newly instantiated object upon success, or sets an error and return undef
or an empty list, depending on the caller's context.
METHODS
for Pod::Coverage autoload
elements
Sets or gets an array object of DB::Object::Query::Element objects.
fields
Read-only. Returns an array object of all the elements field property.
for
This is a shortcut for calling "for" in Module::Generic::Array on this class "elements"
foreach
This is a shortcut for calling "foreach" in Module::Generic::Array on this class "elements"
formats
Read-only. Returns an array object of all the elements format property.
generics
Read-only. Returns an array object of all the elements generic representation.
is_empty
This is a shortcut for calling "is_empty" in Module::Generic::Array on this class "elements"
length
This is a shortcut for calling "length" in Module::Generic::Array on this class "elements"
merge
Provided with one or more DB::Object::Query::Elements objects (including DB::Object::Query::Clause objects that inherit from DB::Object::Query::Elements), and this will merge those objects into this current object.
If the underlying elements are numbered placeholders such as $1
, $2
, or ?1
, ?2
, then they will be properly sorted internally.
It returns the current object.
new_element
Provided with an hash or hash reference of parameter, and this will instantiate a new DB::Object::Query::Element object and return it.
If an error occurred, such as if bad parameters were provided, an error object is set and undef
, or an empty list depending on the context, is returned.
push
Provided with objects of classes DB::Object::Query::Elements or DB::Object::Query::Element, or alternatively an hash reference of property-value pairs needed to instantiate a new DB::Object::Query::Element, and this will add those objects to the stack of elements managed by this class.
If the underlying elements are numbered placeholders such as $1
, $2
, or ?1
, ?2
, then they will be properly sorted internally.
It returns the current object.
query_object
Sets or gets the DB::Object::Query object set for this object.
reset
Various methods return cached value once they have been computed for improved performance. Calling reset
will force re-computing next time either one is called.
Those methods are "fields", "formats", "types" and "values"
sort
Returns a new clone of the current DB::Object::Query::Elements object with its elements sorted based on their index property
types
Read-only. Returns an array object of all the elements type property.
values
Read-only. Returns an array object of all the elements value property.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
DB::Object::Query, DB::Object::Query::Clause, DB::Object::Query::Element, DB::Object
COPYRIGHT & LICENSE
Copyright(c) 2023 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.