Connection class problem

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?

any body else have an idea for this? if i remove __destruct() method then i create sub class and add __destruct at there is it effect to supper class?

I’m not sure I understand the issue, you’re say that defining a __destruct is causing an issue, but the method is empty? What exactly is the code running in __destruct() that’s causing the problem?

Presumably, though, because you’re using a singleton, Conn_DB can never be destructed anyway? Or is that the issue? If it is, it’s a flaw in the singleton pattern and one reason that singletons should be avoided.

i have no idea about your command but i just want to share any idea my mind because i try to looking for some solution :slight_smile:
thank for your reply
Regards,
Heng