|
Posted by weetat on 03/09/07 09:10
Hi all ,
I am using php version 4 which did not have private method access.
How to prevent the user call the object constructor as shown below :
Thanks
Joshua
class MYSQL_DB
{
var $dbConn = null;
/**
* php4 did not have private access method , only php5
* user can call the function, need to find way not allow it ,
but it better use getInstance() to
* have one database instance only
*/
function MYSQL_DB()
{
global $dbHost, $dbUser, $dbPass, $dbName;
$this->dbConn=&ADONewConnection("mysql"); # create a
connection
$this->dbConn->Connect($dbHost, $dbUser, $dbPass, $dbName);
}
/**
* @desc get only one instance created
*/
function &getInstance()
{
static $instance;
if (!isset($instance))
{
$instance=new MYSQL_DB;
}
return $instance;
}
function getConnection() { return $this->dbConn; }
}
[Back to original message]
|