Reply to Re: Create only one instance of Object

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация