my $invocant = shift;
my $type = ref($invocant) || $invocant;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my $self = {
profile_id => 0,
$sth->execute($opts{'template_id'}, $opts{'creator'});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
my $self = $sth->fetchrow_hashref;
$self = _conv_points($self) if (($opts{convert} && $opts{convert} == 1) || $opts{profile_id});
if (scalar(@query_params) < 2) { # If there is no template id or creator type then we cannot delete it
warn sprintf('%s : Cannot delete template as the template id is invalid or non-existant.', $call_type) if !$query_params[0];
warn sprintf('%s : Cannot delete template as the creator type is invalid or non-existant.', $call_type) if !$query_params[1];
- return;
+ return -1;
}
- my $query = "DELETE FROM " . $opts{'table_name'} . " WHERE template_id = ? AND creator = ?";
+ my $query = "DELETE FROM creator_templates WHERE template_id = ? AND creator = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@query_params);
$self->{'template_stat'} = 0;
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
$self->{'template_stat'} = 1;
return $self->{'template_id'};
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(template_id) FROM " . $opts{'table_name'} . ";");
$sth1->execute();
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
return $self->{$attr};
}
- return;
+ else {
+ return -1;
+ }
}
sub set_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my %attrs = @_;
foreach my $attrib (keys(%attrs)) {
=head2 save()
Invoking the I<save> method attempts to insert the template into the database if the template is new and update the existing template record if
- the template exists. The method returns the new record template_id upon success and undef upon failure (This avoids template_ids conflicting with a
+ the template exists. The method returns the new record template_id upon success and -1 upon failure (This avoids template_ids conflicting with a
record template_id of 1). Errors are logged to the Apache log.
example:
=head2 get_attr($attribute)
- Invoking the I<get_attr> method will return the value of the requested attribute or undef on errors.
+ Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
example:
C<my $value = $template->get_attr($attribute);>