addPostalAddress: additional argument to set date_encountered
This commit is contained in:
parent
9a54b77881
commit
16ce9f4bf1
1 changed files with 20 additions and 6 deletions
|
@ -703,14 +703,20 @@ Arguments:
|
||||||
Scalar string that contains the address type. This type will be created in
|
Scalar string that contains the address type. This type will be created in
|
||||||
the database if it does not already exist, so be careful.
|
the database if it does not already exist, so be careful.
|
||||||
|
|
||||||
|
=item $date (optional)
|
||||||
|
|
||||||
|
Scalar string in the format of YYYY-MM-DD, and will be set to the
|
||||||
|
date_encountered for the record if provided. If not provided, the
|
||||||
|
date_encountered will be today.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
Returns the id value of the postal_address table entry.
|
Returns the id value of the postal_address table entry.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub addPostalAddress($$$$) {
|
sub addPostalAddress($$$$;$) {
|
||||||
my($self, $id, $formattedPostalAddress, $addressType) = @_;
|
my($self, $id, $formattedPostalAddress, $addressType, $dateEncountered) = @_;
|
||||||
|
|
||||||
die "addPostalAddress: invalid id, $id" unless $self->_verifyId($id);
|
die "addPostalAddress: invalid id, $id" unless $self->_verifyId($id);
|
||||||
die "addPostalAddress: the formatted postal address must be defined"
|
die "addPostalAddress: the formatted postal address must be defined"
|
||||||
|
@ -728,10 +734,18 @@ sub addPostalAddress($$$$) {
|
||||||
$self->_rollback();
|
$self->_rollback();
|
||||||
die $@ if $@;
|
die $@ if $@;
|
||||||
}
|
}
|
||||||
my $sth = $self->dbh->prepare("INSERT INTO postal_address(formatted_address, type_id, date_encountered)" .
|
my $insertStr = "INSERT INTO postal_address(formatted_address, type_id, date_encountered)" .
|
||||||
"VALUES( ?, ?, date('now'))");
|
"VALUES( ?, ?, ";
|
||||||
|
my $sth;
|
||||||
|
if (defined $dateEncountered) {
|
||||||
|
$insertStr .= "?)";
|
||||||
|
$sth = $self->dbh->prepare($insertStr);
|
||||||
|
$sth->execute($formattedPostalAddress, $addressTypeId, $dateEncountered);
|
||||||
|
} else {
|
||||||
|
$insertStr .= "date('now'))";
|
||||||
|
$sth = $self->dbh->prepare($insertStr);
|
||||||
$sth->execute($formattedPostalAddress, $addressTypeId);
|
$sth->execute($formattedPostalAddress, $addressTypeId);
|
||||||
|
}
|
||||||
my $addressId = $self->dbh->last_insert_id("","","","");
|
my $addressId = $self->dbh->last_insert_id("","","","");
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue