| Server IP : 172.67.178.83 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/corbizrealestate.com/lib/ |
Upload File : |
<?php
/**
* Database layer
* Requirements
* 1. Next constant must be defined:
* DB_HOST
* DB_NAME
* DB_PASS
* DB_LOGIN
*/
class DbMySQL{
var $db_host;
var $db_login;
var $db_pass;
var $db_name;
var $db_link = null;
var $error_report = false;
var $last_err = 0;
function DbMySQL($tHost, $tName, $tLogin, $tPass){
$this->db_host = $tHost;
$this->db_name = $tName;
$this->db_login = $tLogin;
$this->db_pass = $tPass;
}
function connect(){
$this->db_link = mysqli_connect($this->db_host, $this->db_login, $this->db_pass);
if ($this->db_link)
if(mysqli_select_db($this->db_link,$this->db_name))
return true;
return false;
}
function select($tSql){
$query_res = mysqli_query ($this->db_link,$tSql);
if(!$query_res) {
$this->last_err = mysqli_error($this->db_link);
if ($this->error_report)
echo "<br>\nMySQL error: " . $this->last_err."\nQuery was [$tSql]";
return false;
}
$return_res = array();
while ($row = mysqli_fetch_assoc($query_res))
$return_res[] = $row;
return $return_res;
}
function select_row($tSql){
$result = array();
$res = $this->query($tSql, $this->db_link);
if ($res){
$tmp = mysqli_fetch_assoc($res);
if (is_array($tmp)){
$result = $tmp;
}
}else{
return false;
}
return $result;
}
function query($tSql){
$query_res = mysqli_query($this->db_link,$tSql);
if(!$query_res) {
$this->last_err = mysqli_error($this->db_link);
if ($this->last_err){
echo "<br>\nMySQL error: ". $tSql . $this->last_err;
}
}
return $query_res;
}
function escape($str){
$query_res = mysqli_real_escape_string($this->db_link,$str);
if(!$query_res) {
$this->last_err = mysqli_error($this->db_link);
if ($this->last_err){
echo "<br>\nMySQL error: ". $tSql . $this->last_err;
}
}
return $query_res;
}
function insert($tSql){
$res = $this->query($tSql, $this->db_link);
$last_insert_id = 0;
if (mysqli_errno($this->db_link)==0){
$last_insert_id = mysqli_insert_id($this->db_link);
}
return $last_insert_id;
}
function close(){
return mysqli_close($this->db_link);
}
}
?>