DBIx-SQLEngine
view release on metacpan or search on metacpan
SQLEngine/Schema/Table.pm view on Meta::CPAN
(shift)->sqlengine_do('do_insert', @_)
}
# $self->insert_row( \%row );
sub insert_row {
my ($self, $row) = @_;
my $primary = $self->column_primary_name;
my @colnames = grep { $_ eq $primary or defined $row->{$_} }
$self->column_names;
$self->sqlengine_do('do_insert',
( $self->column_primary_is_sequence ? ( sequence => $primary ) : () ),
columns => \@colnames,
values => $row,
);
}
# $self->insert_rows( @hashes );
sub insert_rows {
my $self = shift;
my $rc;
foreach my $row ( @_ ) { $rc += $self->insert_row( $row ) }
$rc
}
########################################################################
=head2 Update to Change Rows
=over 4
=item do_update()
$table->do_update ( %update_clauses ) : $row_count
Calls the corresponding SQLEngine method with the table name and the provided arguments.
=item update_row()
$table->update_row ( $row_hash ) : $row_count
Update this existing row based on its primary key. Uses column_names() and column_primary_is_sequence() to produce the proper clauses. Returns the total number of rows affected, which is typically 1.
=item update_rows()
$table->update_rows ( @row_hashes ) : $row_count
Update several existing rows based on their primary keys. Uses update_row(). Returns the total number of rows affected, which is typically the same as the number of arguments passed.
=back
=cut
# $self->do_update( %clauses);
sub do_update {
(shift)->sqlengine_do('do_update', @_ )
}
# $self->update_row( $row );
sub update_row {
my($self, $row) = @_;
$self->sqlengine_do('do_update',
columns => [ $self->column_names ],
where => $self->primary_criteria( $row ),
values => $row,
);
}
# $self->update_rows( @hashes );
sub update_rows {
my $self = shift;
my $rc;
foreach my $row ( @_ ) { $rc += $self->update_row( $row ) }
$rc
}
########################################################################
=head2 Delete to Remove Rows
=over 4
=item do_delete()
$table->do_delete ( %delete_clauses ) : $row_count
Calls the corresponding SQLEngine method with the table name and the provided arguments.
=item delete_row()
$table->delete_row ( $row_hash_or_id ) : ()
Deletes the provided row from the table. Returns the total number of rows affected, which is typically 1.
=item delete_rows()
$table->delete_rows ( @row_hashes_or_ids ) : ()
Deletes all of the provided rows from the table. Returns the total number of rows affected, which is typically the same as the number of arguments passed.
=back
=cut
# $self->do_delete( %clauses);
sub do_delete {
(shift)->sqlengine_do('do_delete', @_ )
}
# $self->delete_row( $row );
sub delete_row {
my $self = shift;
$self->sqlengine_do( 'do_delete', where => $self->primary_criteria(@_ ) )
}
# $self->delete_rows( @hashes );
sub delete_rows {
my $self = shift;
$self->sqlengine_do( 'do_delete', where => $self->primary_criteria(@_) )
}
########################################################################
########################################################################
=head1 DEFINING STRUCTURES (SQL DDL)
=head2 ColumnSet
=over 4
( run in 1.367 second using v1.01-cache-2.11-cpan-6736b670a1e )