Re: DataObject connect problem using sessions

From: Date: Thu, 05 Dec 2002 00:29:17 +0000
Subject: Re: DataObject connect problem using sessions
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2898@lists.php.net to get a copy of this message
A quick update... on the second script, if create a new object, then call setFrom() on it, and then try to update() the first object (which was stored in the session) it works fine: //------- $testuser2 = new DataObjects_User; $testuser2->setFrom($testuser); $testuser->update(); //------- without the setFrom() call, it fails to work. What's going on here? Leigh Caplan maelman@u.washington.edu On Wed, 4 Dec 2002, L. Caplan wrote: > I'm faced with a rather odd bug for which I think I've figured out the > cause, yet can't really think of a good solution. The context where I > originally found it is a bit different that what I describe here, but I > wrote some simple code to help narrow down the problem. > > Consider the following code: > > //sessiontest1.php > //---------------- > include('myinclude.inc.php'); > session_start(); > > if(!session_is_registered("testuser")) > session_register("testuser"); > > $testuser = new DataObjects_User; > > $testuser->get('user_id', 1); > > $testuser->active = 0; > > $testuser->update(); > //---------------- > > That code works perfectly, and the update goes off without a hitch. > Everything seems fine, however, in the next document, I try to used the > $testuser object which was stored in the session... > > //sessiontest2.php > //---------------- > include("myinclude.inc.php"); > session_start(); > > print_r($testuser); > > $testuser->active = 1; > > $testuser->update(); > //---------------- > > This *should* work, but instead, I get this error: > "Fatal error: Call to a member function on a non-object in DataObject.php > on line 1022" > > The contents of that line are: > $results[$this->_DB_resultid] = $__DB->query($string); > > so, further investigation revealed that $__DB was in fact NULL, as were > the $connections and $results variables set at the top of the function. > so, it appears as though calls to PEAR::getStaticProperty are returning > NULL values for some reason, though I've got no idea why. > > If I create a new object of the same class (User) and use setFrom(), then > attempt to update, it works just fine. This issue only comes up on objects > which were created in other scripts, then stored in sessions. > > I'd really like to figure out why this is happening, because as you can > imagine, it potentially affects a lot of functionality across my > application. Thanks very much in advance for any help! > > > Leigh Caplan > maelman@u.washington.edu > >

« previous php.pear.general (#2898) next »