Example #1
0
 /**
  * Helper function to setup MySQL connection.
  */
 public static function mysql_connect()
 {
     // Make sure to always create a new link, since each
     // mysql_connect() is matched with an mysql_close() through
     // our RAII-enabling SqlQuery class
     $con = mysql_connect(Config::get_mysql_server(), Config::get_mysql_user(), Config::get_mysql_password(), TRUE);
     if (!$con) {
         throw new Exception("mysql_connect() failed: " . mysql_error());
     }
     mysql_select_db(Config::get_mysql_database(), $con);
     if (mysql_errno($con)) {
         throw new Exception("mysql_select_db() failed: " . mysql_error($con));
     }
     return $con;
 }