/usr/share/libalzabo-perl/mason/widgets/insert_or_update is in libalzabo-perl 0.92-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 49 50 | <%doc>
=pod
=head1 NAME
insert_or_update
=head1 SYNOPSIS
<& insert_or_update, table => $table, %ARGS &>
=head1 DESCRIPTION
A simple component to perform an insert or update based on the values
of %ARGS. An insert is done if the primary key columns for the table
are not defined in C<%ARGS>. Otherwise an update is done.
=head1 PARAMETERS
=over 4
=item * table
An <Alzabo::Table> object into which a new row is inserted or an
existing row is updated.
=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 row that was inserted or updated.
=cut
</%doc>
<%args>
$table
</%args>
<%init>
my $insert = 1;
foreach my $c ( $table->primary_key )
{
$insert = 0 unless defined $ARGS{ $c->name };
}
return $insert ? $m->comp( 'insert', %ARGS ) : $m->comp( 'update', %ARGS );
</%init>
|