File: /home/cafsindia/allyindian_com/backend/customers/sbltt_lib/dbobject.php
<?php
/**********************************************************
Filename: dbobject.php
Description: Mother class for all DB related operations
Author: Jaffer
Created on: NOV, 09 2018
Approved on:
Reviewed on:
------------------------------------------------------------
Modification Details
Changed by:
------------------------------------------------------------
**********************************************************/
class DBObject{
protected $db;
private $host = "localhost";
private $username = "root";
private $password = "Newcafs_123*2018";
private $database = "sblttweb_backend";
public function open_db(){
$this->db = new mysqli($this->host, $this->username, $this->password, $this->database);
if(mysqli_connect_errno()){
return false;
}else{
return true;
}
}
public function get_db(){
return $this->db;
}
public function time_stamp(){
$date = new DateTime($dateString);
}
public function query($tableName,$where=null,$fieldName=null){
$tableName = "sblttweb_".$tableName;
if($fieldName == null)
$fieldName = "*";
$getFetchQuery = 'select '.$fieldName.' from '.$tableName;
if($where != null)
$getFetchQuery .= ' where '.$where;
$result = mysqli_query($this->db,$getFetchQuery);
if($result){
return $result;
}else{
return false;
}
}
public function result($result){
$data = array();
while ($obj = mysqli_fetch_object($result)){
if($obj){
$data[] = $obj;
}
}
return $data;
}
public function num_rows($result){
return mysqli_num_rows($result);
}
function runQuery($query) {
$result = mysqli_query($this->db,$query);
return $result;
}
public function close_db(){
mysqli_close($this->db);
}
}
?>