View | Details | Raw Unified | Return to bug 22472
Collapse All | Expand All

(-)a/C4/Installer.pm (-1 / +15 lines)
Lines 30-36 use vars qw(@ISA @EXPORT); Link Here
30
BEGIN {
30
BEGIN {
31
    require Exporter;
31
    require Exporter;
32
    @ISA = qw( Exporter );
32
    @ISA = qw( Exporter );
33
    push @EXPORT, qw( foreign_key_exists index_exists column_exists );
33
    push @EXPORT, qw( foreign_key_exists index_exists column_exists TableExists);
34
};
34
};
35
35
36
=head1 NAME
36
=head1 NAME
Lines 527-532 sub index_exists { Link Here
527
527
528
sub column_exists {
528
sub column_exists {
529
    my ( $table_name, $column_name ) = @_;
529
    my ( $table_name, $column_name ) = @_;
530
    return unless TableExists($table_name);
530
    my $dbh = C4::Context->dbh;
531
    my $dbh = C4::Context->dbh;
531
    my ($exists) = $dbh->selectrow_array(
532
    my ($exists) = $dbh->selectrow_array(
532
        qq|
533
        qq|
Lines 537-542 sub column_exists { Link Here
537
    return $exists;
538
    return $exists;
538
}
539
}
539
540
541
sub TableExists { # Could be renamed table_exists for consistency
542
    my $table = shift;
543
    eval {
544
                my $dbh = C4::Context->dbh;
545
                local $dbh->{PrintError} = 0;
546
                local $dbh->{RaiseError} = 1;
547
                $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 });
548
            };
549
    return 1 unless $@;
550
    return 0;
551
}
552
553
540
=head1 AUTHOR
554
=head1 AUTHOR
541
555
542
C4::Installer is a refactoring of logic originally from installer/installer.pl, which was
556
C4::Installer is a refactoring of logic originally from installer/installer.pl, which was
(-)a/installer/data/mysql/updatedatabase.pl (-16 lines)
Lines 17874-17894 foreach my $file ( sort readdir $dirh ) { Link Here
17874
17874
17875
=head1 FUNCTIONS
17875
=head1 FUNCTIONS
17876
17876
17877
=head2 TableExists($table)
17878
17879
=cut
17880
17881
sub TableExists {
17882
    my $table = shift;
17883
    eval {
17884
                local $dbh->{PrintError} = 0;
17885
                local $dbh->{RaiseError} = 1;
17886
                $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 });
17887
            };
17888
    return 1 unless $@;
17889
    return 0;
17890
}
17891
17892
=head2 DropAllForeignKeys($table)
17877
=head2 DropAllForeignKeys($table)
17893
17878
17894
Drop all foreign keys of the table $table
17879
Drop all foreign keys of the table $table
17895
- 

Return to bug 22472