FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » out of sheer curiosity...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: out of sheer curiosity... [message #177624 is a reply to message #177620] Tue, 10 April 2012 23:53 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 4/10/2012 6:13 PM, Thomas Mlynarczyk wrote:
> Jerry Stuckle schrieb:
>
>> I no longer even try to store objects in the session. It's hopeless.
>
> Why? I never had any real problems with storing objects in the session.
> Or maybe I was just lucky ;-)
>
>> For instance - what if one of the things your object needs is a
>> database connection? And what if you have several objects using that
>> same connection? There is no way to pass an existing database
>> connection to __wakeup(). You either have to use a global variable,
>> restricting variable names in the rest of your code and limiting
>> flexibility, or create a new connection in the __wakeup() call or
>> remember to call another method to set the database connection after
>> unserializing the object.
>
> MyDatabaseSingleton::getInstance() ?
>

What if you don't want a singleton? Many times I've had the need to
access different databases, for instance. You are limiting the
versatility of the class.

>> None are good answers - but all could be easily handled with proper
>> use of constructors.
>
> And how would a "proper use of constructors" solve the above problem?
> Even if unserialize() called __construct(), you would have no chance to
> pass any arguments to the constructor.
>
> Greetings,
> Thomas
>

By definition you can pass arguments to the constructor. That's why
unserialize() is not a good implementation.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 5.4 windows installer.
Next Topic: Does PHP5 treat $_SERVER['PHP_AUTH_USER']) differently?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 00:11:32 GMT 2024

Total time taken to generate the page: 0.03883 seconds