File: /home/cafsindia/lifemaze_in/lp_lib/dbobject.php
<?php
/**********************************************************
Filename: dbobject.php
Description: Mother class for all DB related operations
Author: uday
Created on: AUG, 01 2018
Approved on:
Reviewed on:
------------------------------------------------------------
Modification Details
Changed by:
------------------------------------------------------------
**********************************************************/
class DBObject{
protected $db;
private $host = "localhost";
private $username = "cafsindia_adminn";
private $password = "60qiBQYcS_@5";
private $database = "lifemaze";
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 = "lp_".$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);
}
}
?>