Exemple #1
0
 /**
  * This method will make the database connection using mysql_connect() function
  * @return boolean true if connected to the database successfully
  */
 public function dbConnect()
 {
     /*
      * TODO: The capturing of database errors should be done without returning true or false; Proper exceptions
      * should be thrown instead
      */
     if (!@($this->conn = mysql_connect($this->myHost . ':' . $this->myHostPort, $this->userName, $this->userPassword))) {
         $exception_handler = new ExceptionHandler();
         $exception_handler->dbexNoConnection();
         exit;
     } else {
         if ($this->conn) {
             mysql_query("SET NAMES 'utf8'");
             if (mysql_select_db($this->db_name)) {
                 mysql_query("SET @orangehrm_user = '******';");
                 return true;
             } else {
                 $exception_handler = new ExceptionHandler();
                 $exception_handler->dbexNoDatabase();
                 exit;
             }
         } else {
             return false;
         }
     }
     if ($this->conn) {
         mysql_select_db($this->db_name);
         mysql_query("SET @orangehrm_user = '******';");
         return true;
     } else {
         $exception_handler = new ExceptionHandler();
         $exception_handler->dbexNoDatabase();
         return false;
     }
 }
Exemple #2
0
 function dbConnect()
 {
     //$this -> conn = mysql_connect($this->myHost, $this->userName, $this->userPassword);
     if (!@($this->conn = mysql_connect($this->myHost . ':' . $this->myHostPort, $this->userName, $this->userPassword))) {
         $exception_handler = new ExceptionHandler();
         $exception_handler->dbexNoConnection();
         exit;
     } else {
         if ($this->conn) {
             mysql_query("SET NAMES 'utf8'");
             if (mysql_select_db($this->db_name)) {
                 return true;
             } else {
                 $exception_handler = new ExceptionHandler();
                 $exception_handler->dbexNoDatabase();
                 exit;
             }
         } else {
             return false;
         }
     }
     if ($this->conn) {
         mysql_select_db($this->db_name);
         return true;
     } else {
         $exception_handler = new ExceptionHandler();
         $exception_handler->dbexNoDatabase();
         //exit;
         return false;
     }
 }