|
Posted by J.O. Aho on 03/09/07 12:50
weetat wrote:
> 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()
> {
if(_MYSQL_CLASS) { return; }
define(_MYSQL_CLASS,true);
> global $dbHost, $dbUser, $dbPass, $dbName;
> $this->dbConn=&ADONewConnection("mysql"); # create a
> connection
> $this->dbConn->Connect($dbHost, $dbUser, $dbPass, $dbName);
> }
should prevent anyone from using constructor as a function, even if you use
two objects of the same class, the constructor will only create one connection
together.
--
//Aho
[Back to original message]
|