public static function get_connection() { if (!Dal::$_connection) { global $peepagg_dsn; Dal::$_connection = DB::connect($peepagg_dsn, array("autofree" => true)); if (Dal::$_connection instanceof PEAR_Error) { $msg = Dal::$_connection->getMessage(); if (strpos($msg, "no such database") != -1) { ?> <h1>Database not found</h1> <p>Please check your <code>AppConfig.xml</code> file and ensure that the <code>$peepagg_dsn</code> variable is set and points to a valid database.</p> <p>Currently, either the database doesn't exist, the user doesn't exist, or the password in <code>$peepagg_dsn</code> is incorrect.</p> <?php exit; } // otherwise we throw an exception throw new PAException(DB_CONNECTION_FAILED, "Database connection failed"); } // connection succeeded - turn off automatic committing Dal::$_connection->autoCommit(FALSE); } return Dal::$_connection; }