db = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
$this->db->set_charset("utf8");
if (mysqli_connect_errno()) {
echo 'Connect error: ' . mysqli_connect_error();
$this->db->close();
exit;
}
$sqlMode = $this->getOne('SELECT @@SQL_MODE');
if( $sqlMode != 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' ) $this->query("SET sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';");
}
function __destruct(){
$this->db->close();
}
public function getAll($strQuery){
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) printf("Errormessage: %s\n $strQuery", $this->db->error);
//$result = $this->db->query($strQuery);
if($this->db->affected_rows>=0){
while ( $row = $result->fetch_array(MYSQLI_ASSOC)) {
$rows[] = $row;
}
return $rows;
}
else return false;
}
public function getRow($strQuery){
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) printf("Errormessage: %s\n $strQuery", $this->db->error);
return $result->fetch_assoc();
}
public function getOne($strQuery){
//echo $strQuery;
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) {
printf("Errormessage: %s\n $strQuery", $this->db->error);
}
$row = $result->fetch_array(MYSQLI_NUM);
return $row[0];
}
public function query($strQuery){
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) printf("Errormessage: %s\n $strQuery", $this->db->error);
if($this->db->affected_rows>=0) return true;
else return false;
}
}
class DatabaseEbooks {
public $db;
function __construct(){
$this->db = new mysqli(DB2_HOSTNAME, DB2_USERNAME, DB2_PASSWORD, DB2_DATABASE, DB2_PORT);
$this->db->set_charset("utf8");
if (mysqli_connect_errno()) {
echo 'Connect error: ' . mysqli_connect_error();
$this->mysqli->close();
exit;
}
}
public function getAll($strQuery){
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) printf("Errormessage: %s\n $strQuery", $this->db->error);
//echo $strQuery;
//$result = $this->db->query($strQuery);
if($this->db->affected_rows>=0){
$row = array();
while ( $row = $result->fetch_array(MYSQLI_ASSOC)) {
$rows[] = $row;
}
return $rows;
}
else return false;
}
public function getRow($strQuery){
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) printf("Errormessage: %s\n $strQuery", $this->db->error);
return $result->fetch_assoc();
}
public function getOne($strQuery){
//echo $strQuery;
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) {
printf("Errormessage: %s\n $strQuery", $this->db->error);
}
$row = $result->fetch_array(MYSQLI_NUM);
return $row[0];
}
public function query($strQuery){
if (!$result = $this->db->query($strQuery) AND APP_DATABASE_ERRORS == 1) printf("Errormessage: %s\n $strQuery", $this->db->error);
if($this->db->affected_rows>=0) return true;
else return false;
}
}
?>
Fatal error: Uncaught Error: Class 'Database' not found in /var/www/vhosts/71new.pl/czytio_test/_onyx/includes/init.php:52
Stack trace:
#0 /var/www/vhosts/71new.pl/czytio_test/_onyx/index.php(2): require_once()
#1 {main}
thrown in /var/www/vhosts/71new.pl/czytio_test/_onyx/includes/init.php on line 52