Connecting to the Database

The hook hookDatabase_Connect (pedserve-hook-database.pl) is used by all Pedserve scripts to open the connection to the database. Pedserve uses the DBI.pm package to handle the database connection.

The standard implementation of this hook causes the database connection to be made using the parameters set up in the Pedserve configuration file ($custom_strDbName, $custom_strDbHost, $custom_strDbUser and $custom_strDbPass).

We expect that most users will not need to alter this hook.

# Connect to database, returning DBI handle.
# Or, fatal error if that fails.
#
# OPTIONAL
# Arg 1 - reference to map for future additional arguments; possibly undefined
sub hookDatabase_Connect {
    my ($rmArgsEx) = @_;

    # The example just shows a vanilla database connection being made
    # using the  parameters set up in pedserve-customize-sys.pl.
    my $hDBI = DBI->connect(
                    "dbi:mysql:database=$::custom_strDbName:$::custom_strDbHost",
                    $::custom_strDbUser, $::custom_strDbPass);
    if (!defined($hDBI)) {
        &pdsFatal('db connection error');
    }

    return $hDBI;
}

USEFUL LINKS:
 EULA
 Pedserve Editions
 Sample City
 Consultancy
 Data Preparation
 Installation
 Regular Expressions
 Similarity Searching
 Configuration File
 Setup Script
 Stylesheet
 Database Design
 Hooks
 Date/Time
 User Defined Fields
 User Defined Records
 Display Fields Definitions
 Ordering Fields Definitions
 Highlighting
 Page Layout
 Field Definitions
 Field Formatting
 Shortcut Query Buttons
 Plates
 Command Buttons
 Connecting to the Database
 Warning Footer Message