Re: Simple class declaration returns error [SOLVED]

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

 



Jochem,

Thank you for your advice. I was able to use your suggested code to develop the results I wanted.

I found I could simplify the "self" references down to just the name of the class.

The syntax I ended up with is

class database {
private static $database;
public static function getDB()
{
if (!isset($database))
$database = new database();
return $database;
}
private function __construct()
{
  $this->dbConnect();
}
private function dbConnect()
{
// Database connection
  return $result;
}
public function getData($type, $id)
{
// SQL Query
return $data;
}


And I call it like this:
$data = database::getDB()->getData($arg1, arg2);

Thank you for your time and advice.

--
Dave M G

--
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