Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: [Paul] Database Field Advice

Quote Reply
Re: [Paul] Database Field Advice In reply to
Hi,

I got the plugin working using the following but I am not sure about how to handle the add_success

part indicated in red. It works with (1) but I'm not sure what it really should be.

Any ideas?

Thanks.

Simon.



sub split_add_record {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'add_record'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#
my ($self) = @_;
# Do something useful here
# Ignores the plugin if this is not contact table
($self->{cgi}->{db} ne 'public_holiday') and return @_;
GT::Plugins->action ( STOP );
#----------------------------------------------------------------------

my $splitdate;
my @dates = split ',', $IN->param('public_holiday_202');
foreach $splitdate (@dates) {

$self->{cgi}->{public_holiday_202}=$splitdate;


#----------------------------------------------------------------------
return $self->home($self->_language('PER_ADD')) unless ( $self->{user}->{add_p} );

#------------demo code----------------


# add data to related table
return $self->sadd_record() if ( $self->{cgi}->{sdb} and $self->{cgi}->{sdo} );



# Turn arrays into delimited fields
$self->format_insert_cgi;
if ( $self->{cfg}->{'auth_user_field'} ) {
$self->{cgi}->{$self->{cfg}->{'auth_user_field'}} = $self->{user}->{'Username'};
}

# Check foreign keys
my $msg = $self->_check_fk();
($msg) and return $self->add_form($msg);


# Setup the language for GT::SQL.
local $GT::SQL::ERRORS->{ILLEGALVAL} = $self->_language('ADD_ILLEGALVAL');
local $GT::SQL::ERRORS->{UNIQUE} = $self->_language('ADD_UNIQUE');
local $GT::SQL::ERRORS->{NOTNULL} = $self->_language('ADD_NOTNULL');

if ( defined (my $ret = $self->{db}->add($self->{cgi})) ) {



$self->auth_logging('add record ') if ( $self->{cfg}->{log_file} );

#------------demo code-----------


#Don't call up the success page
###$self->add_success($ret);
}
else {
local $^W;
my $error = $GT::SQL::error;
$error =~ s/\n/<br>\n<li>/g;
$self->add_form("<font color=red><ul><li>$error</ul></font>");
}

#end for
}


$self->add_success(1);

#end sub
}

# Always end with a 1.
1;
Subject Author Views Date
Thread Database Field Advice jai 5334 Jan 21, 2003, 3:33 AM
Post Re: [jai] Database Field Advice
jaspercram 5149 Jan 21, 2003, 7:27 AM
Thread Re: [jai] Database Field Advice
Paul 5157 Jan 21, 2003, 8:44 AM
Thread Re: [Paul] Database Field Advice
jai 5133 Jan 24, 2003, 4:09 PM
Thread Re: [jai] Database Field Advice
Paul 5133 Jan 24, 2003, 4:14 PM
Thread Re: [Paul] Database Field Advice
jai 5132 Jan 24, 2003, 5:35 PM
Thread Re: [jai] Database Field Advice
Paul 5145 Jan 24, 2003, 5:46 PM
Post Re: [Paul] Database Field Advice
jai 5091 Jan 26, 2003, 11:15 PM
Post Re: [Paul] Database Field Advice
jai 5082 Jan 28, 2003, 8:59 PM