if (!self::$instance) { self::$instance = (include_once "{$db_type}.php"); //new PDO(driver, db_settings); self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } return self::$instance; } /** * * Like the constructor, we make __clone private * so nobody can clone the instance * */ private function __clone() { } } /*** end of class ***/ /***************************************************************/ /* USE THE DB class */ /***************************************************************/ try { /*** query the database ***/ $result = CONNECT::getInstance()->query("SELECT * FROM {$table_type}"); /*** loop over the results ***/ foreach ($result as $row) { print $row["{$table_type}_title"] . ' - ' . $row["{$table_type}_image"] . '<br />'; } } catch (PDOException $e) { echo $e->getMessage(); }