Loomy Posted December 8, 2006 Share Posted December 8, 2006 I'm using ADOdb for my database backend, but I'm using it via my own [b]singleton[/b] database class. This is the most important parts of it:[code]<?phprequire_once('adodb/adodb.inc.php');class DB{ private static $instance; private $adodb; private function __construct() { $dsn = 'mysql://*********'':*******@**********?persist'; $adodb = NewADOConnection($dsn); if(!$adodb) { die("Could not connect"); } } public static function getInstance() { if(empty(self::$instance)) { self::$instance = new DB(); } return self::$instance; } // ... public function select($sql) { return self::$adodb->Execute($sql); }[/CODE]And the code to test if it's working:[CODE]<?phprequire_once('database/DB.class.php'); $db = DB::getInstance(); $rs = $db->select('SELECT * FROM `user_level`');echo $rs->_numOfFields;?>[/CODE]Error message:Fatal error: Access to undeclared static property: DB::$adodb in (...)DB.class.php on line 66Line 66 is the one with [i]return self::$adodb->Execute($sql);[/i] in select()Any ideas how I can fix this? And what's wrong? Link to comment https://forums.phpfreaks.com/topic/29946-adodb-singleton-undeclared-static-property/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.