green bean question on singleton php5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Hi,

I am implementing this

class dbaccess{
  static $db=null;
  static $othervar=33;
	
  private  function dbaccess(){
    dbaccess::$db= new mysqli("localhost",USER,PASSWD,DB);
    if(mysqli_connect_errno()){
      echo "no way";
    }
  }
	
public static function GetDb(){
  if(dbaccess::$db==null){
  dbaccess::$db= new dbaccess();
  }
  return  dbaccess::$db;
	
  }
}


$db=dbaccess::GetDE();

$db->query(..................);

will fail...with Call to undefined method dbaccess::query()

apparently $db is of type dbaccess... and thus has not does not have query implemented....


any hhelp appreciated.....

JCG

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux