Re: Any idea how to do it right?



Hi Jerry.

Thanks for your reply. I was thinking about making a singleton and then use it in my classes constructor to get database object but that would mean three things.

1. I would have to hard code name of database classes (singletons) in other classes.

2. Require to configure singleton classes, at the beginning of every script, even if database connection is not used every time script is running.

3. Singletons would work as global variables so would be accessible at any time to every peace of code. PHP classes have global scope.

I was hoping for some nice method to pass database abstraction objects in constructor, but that would mean passing a lot of parameters to aggregate class.


Ralph
.



Relevant Pages

  • Re: real world singleton class example?
    ... I've used them for database classes before. ... What is the use of a singleton is when running PHP? ... table1 and table2 tables within the database. ...
    (comp.lang.php)
  • Re: real world singleton class example?
    ... I've used them for database classes before. ... What is the use of a singleton is when running PHP? ... table1 and table2 tables within the database. ...
    (comp.lang.php)
  • Re: Database objects? Persistence? Sql Server woes
    ... my max connections on the database fairly easily (given how my script was ... written) and therefore have used the singleton pattern on my database ... occurring given I'm indicating that Set belongs to Database and therefore ... database object between each class. ...
    (comp.lang.python)
  • Re: real world singleton class example?
    ... I've used them for database classes before. ... What is the use of a singleton is when running PHP? ... table1 and table2 tables within the database. ...
    (comp.lang.php)
  • Re: database access pattern
    ... one instance of a DAL so a singleton would work well. ... of design is to isolate the data access part into its own area, ... > How does everyone design the database access layer in an asp.net ... > inheriting class creation, whether or not that class will do db access. ...
    (microsoft.public.dotnet.general)