Syphon Posted April 25, 2008 Share Posted April 25, 2008 I'm experiencing a very odd error. I'm converting our Data Access object to use the mysqli api. The conversion went through fine and the object uses the new api as expected. There is one page, with one query in particular that seems to "unset" the mysqli object. A null result set is returned. When I try to access the $MySQLi->errno property, I get this error Unknown Error: Couldn't fetch mysqli Suddenly my object becomes broken! I'm not calling ANY close methods on the result objects or mysqli objects. Many of the other pages work fine, and executing the query in phpmyadmin yields valid results. Google turned up only a handful of links related to this issue. Is there obscure issues with the mysqli api that aren't documented? As I mentioned before, I'm not closing any of the returned result objects. Could it be a reached a limit and broke mysqli? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 25, 2008 Share Posted April 25, 2008 As I mentioned before, I'm not closing any of the returned result objects. Could it be a reached a limit and broke mysqli? That doesn't sound consitent with the fact that it's the same page. Comment out all of your code, uncomment block by block, you'll find it. Quote Link to comment Share on other sites More sharing options...
Syphon Posted April 25, 2008 Author Share Posted April 25, 2008 Found the issue. It's a little complicated to explain, but I'll give it a shot. Each table of the database has it's respective class in php. Each class has a load function, which will take the parameter give and load itself The DAL object which every single class uses, is referenced to one object. In other words, every single class uses the exact same object to talk to the database. One connection and tons of queries When a class is serialized (the only one that is serialized currently is the user object), the DAL class is serialized along with it. Now the user navigates to another page. A new DAL is constructed right off the bat. The session is checked and if someone exists, the page user object is instantiated and the session is unserialized. That's the problem. The unserialized DAL in the newly created user object and the DAL object constructed on the page first load are not the same objects. It unserializes successfully, but I'm guessing that something inside the mysqli object needed to be refreshed. Simply adding a __wakeup() and pointing the user object DAL back to the newly constructed one fixed this issue. Hope that made sense. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.