Exemplo n.º 1
0
 public function __construct()
 {
     $DB_CONNECT = new DB_CONNECT();
     $this->connection = new \mysqli($DB_CONNECT->getHost(), $DB_CONNECT->getUsername(), $DB_CONNECT->getPassword(), $DB_CONNECT->getName());
     if ($this->connection->connect_errno) {
         echo "Failed to connect to MySQLI: " . $this->connection->connect_error;
     }
 }
Exemplo n.º 2
0
 public function __construct()
 {
     try {
         $DB_CONNECT = new DB_CONNECT();
         $this->databaseConnection = mysql_connect($DB_CONNECT->getHost(), $DB_CONNECT->getUsername(), $DB_CONNECT->getPassword()) or die("Unable to connect to MySQL");
         $this->selectedDatabase = mysql_select_db($DB_CONNECT->getDatabase(), $this->databaseConnection) or die("Could not select database");
     } catch (Exception $error) {
         echo 'Caught exception: ', $error->getMessage(), "\n";
     }
 }