File: insert

package info (click to toggle)
libalzabo-perl 0.92-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,200 kB
  • sloc: perl: 15,060; makefile: 4
file content (48 lines) | stat: -r--r--r-- 746 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<%doc>
=pod

=head1 NAME

insert

=head1 SYNOPSIS

  <& insert, table => $table, %ARGS &>

=head1 DESCRIPTION

A simple component to perform an insert based on the values of %ARGS.

=head1 PARAMETERS

=over 4

=item * table

An <Alzabo::Table> object into which a new row will be inserted.

=back

The rest of the arguments should simply be the C<%ARGS> hash as passed
to the calling component.  This component will extract the relevant
column values from that hash.

=head1 RETURNS

The new row that was inserted is returned.

=cut
</%doc>
<%args>
$table
</%args>
<%init>
my %data;
foreach my $c ( $table->columns )
{
    $data{ $c->name } = $ARGS{ $c->name }
	if exists $ARGS{ $c->name };
}

return $table->insert( values => \%data );
</%init>