BEGIN {
require Exporter;
@ISA = qw( Exporter );
- push @EXPORT, qw( foreign_key_exists index_exists column_exists );
+ push @EXPORT, qw( foreign_key_exists index_exists column_exists TableExists);
};
=head1 NAME
sub column_exists {
my ( $table_name, $column_name ) = @_;
+ return unless TableExists($table_name);
my $dbh = C4::Context->dbh;
my ($exists) = $dbh->selectrow_array(
qq|
return $exists;
}
+sub TableExists { # Could be renamed table_exists for consistency
+ my $table = shift;
+ eval {
+ my $dbh = C4::Context->dbh;
+ local $dbh->{PrintError} = 0;
+ local $dbh->{RaiseError} = 1;
+ $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 });
+ };
+ return 1 unless $@;
+ return 0;
+}
+
+
=head1 AUTHOR
C4::Installer is a refactoring of logic originally from installer/installer.pl, which was
=head1 FUNCTIONS
-=head2 TableExists($table)
-
-=cut
-
-sub TableExists {
- my $table = shift;
- eval {
- local $dbh->{PrintError} = 0;
- local $dbh->{RaiseError} = 1;
- $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 });
- };
- return 1 unless $@;
- return 0;
-}
-
=head2 DropAllForeignKeys($table)
Drop all foreign keys of the table $table