dear all here my connection class
<?php
class Conn_DB {
private static $_cbInstance = NULL;
private function __construct(){}
public function __clone(){
trigger_error("Error",E_USER_ERROR);
}
public function __wakeup(){
trigger_error("Error",E_USER_ERROR);
}
public static function getCBConnect(){
if(!isset(self::$_cbInstance)){
try{
self::$_cbInstance = new PDO("mysql:host=localhost;dbname=testingDB;charset=UTF-8","username","password");
}
catch (PDOException $e){
die($e->getMessage());
}
return self::$_cbInstance;
}
}
public function __destruct() {
}
}
nothing wrong but when i used my select class
<?php
class SelectDatabase{
function select($connect,$field,$table){
$query = "SELECT ".$field." FROM ".$table;
$stmt = $connect->prepare($query);
$stmt->execute();
return $stmt;
}
function selectWhere($connect,$field,$table,$whereclause){
$query = "SELECT ".$field." FROM ".$table." ".$whereclause;
$stmt = $connect->prepare($query);
$stmt->execute();
return $stmt;
}
public function __destruct(){}
}
?>
here my function
<?php
function fnc_select($table)
{
$conn = Conn_DB::getCBConnect();
$sel = new SelectDatabase();
$statement = $sel->select($conn," * " ,$table);
return $statement;
}
?>
it work actually but the problem is my public function __destruct(){} when i want to use same select class for another in the same page it fatal error because i my connection class was __destruct so any way use 1 connection and 1 select class for whole project?