| Persistence-Entity documentation | Contained in the Persistence-Entity distribution. |
Persistence::Entity::Query - Database entity query.
SQL::Query
|
+----Persistence::Entity::Query
my $entity_manager = $class->new(connection_name => 'my_connection');
$entity_manager->add_entities(SQL::Entity->new(
name => 'emp',
unique_expression => 'empno',
columns => [
sql_column(name => 'ename'),
sql_column(name => 'empno'),
sql_column(name => 'deptno')
],
indexes => [
sql_index(name => 'emp_idx1', columns => ['empno'])
]
));
package Employee;
use Abstract::Meta::Class ':all';
use Persistence::ORM ':all';
entity 'emp';
column empno => has('$.no') ;
column ename => has('$.name');
column deptno => has('$.deptno');
my $query = $entity_manager->query(emp => 'Employee');
$query->set_offset(20);
$query->set_limit(5);
my @emp = $query->execute();
# do stuff $emp[0]->name
my $query = $entity_manager->query('emp');
$query->set_offset(20);
$query->set_limit(5);
my @emp = $query->execute();
# do stuff $emp[0]->{ename}
Represents database query based on entity definition.
None
The Persistence::Entity::Query module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
Adrian Witas, adrian@webapp.strefa.pl
| Persistence-Entity documentation | Contained in the Persistence-Entity distribution. |
package Persistence::Entity::Query; use strict; use warnings; use vars qw($VERSION); use Abstract::Meta::Class ':all'; use base 'SQL::Query'; $VERSION = 0.02;
has '$.name' => (required => 1);
has '&.cursor_callback' => (required => 1);
has '&.condition_converter_callback' => (required => 1);
sub execute { my ($self, $requested_columns, @args) = @_; my $condition_converter_callback = $self->condition_converter_callback; my $condition = $condition_converter_callback->(@args); my ($sql, $bind_variables) = $self->query($requested_columns, $condition); my $cursor_callback = $self->cursor_callback; $cursor_callback->($self, $sql, $bind_variables); }
sub query_setup { my $self = shift; $self->_entity_limit_wrapper->query_setup(@_); } 1; __END__
1;