Exemplo n.º 1
0
 /** This function will initialize the connection to the database, setting $conDB, if it hasn't already
  * been done.   This should be called in the regular constructor, and in every static function that requires
  * the use of the $conDB variable. */
 private static function initialize()
 {
     /* Only bother with this function if the database connection hasn't already been made.  */
     if (!clsDB::$conDB) {
         clsDB::$conDB = mysql_pconnect(DBHOST, DBUSERNAME, DBPASSWORD);
         if (!clsDB::$conDB) {
             throw new Exception("Error connecting to database server: " . mysql_error());
         }
         if (!mysql_select_db(DBNAME, clsDB::$conDB)) {
             throw new Exception("Error selecting database: " . mysql_error());
         }
     }
 }