Re: [PHP-DB] losing MySQL resource

2009-12-19 Thread Stan
OK. I finally understand. When I want to save an object across client requests, I need to serialize() that object into a session variable and when I need to use it later I need to unserialize() it into a local variable. If I modify the object, I need to replace the serialized session variable. I

Re: [PHP-DB] losing MySQL resource

2009-11-12 Thread Chris
Stan wrote: I don't understand the process. When session_start() reconnects to a (the) session, objects saved as $_SESSION variables must be "recreated". To do this requires the class definition. So the class definition must be loaded prior to calling session_start(). Some other languages I

Re: [PHP-DB] losing MySQL resource

2009-11-12 Thread Stan
I don't understand the process. When session_start() reconnects to a (the) session, objects saved as $_SESSION variables must be "recreated". To do this requires the class definition. So the class definition must be loaded prior to calling session_start(). Some other languages I've written in

RE: [PHP-DB] losing MySQL resource

2009-11-11 Thread Ford, Mike
> -Original Message- > From: Nehemias Duarte [mailto:ndua...@aflac.com] > Sent: 11 November 2009 14:25 > To: Stan; php-db@lists.php.net > Subject: RE: [PHP-DB] losing MySQL resource > > I was under the impression that session_start() had to be the FIRST > thing ra

RE: [PHP-DB] losing MySQL resource

2009-11-11 Thread Nehemias Duarte
I was under the impression that session_start() had to be the FIRST thing ran in the script. Is this incorrect? >>OK. The secret, as has been stated here before, is to load the class definitions BEFORE calling session_start(). Thanks to everyone. ""Andy Shellam (Mailing Lists)"" wrote in mess

Re: [PHP-DB] losing MySQL resource

2009-11-11 Thread Stan
OK. The secret, as has been stated here before, is to load the class definitions BEFORE calling session_start(). Thanks to everyone. ""Andy Shellam (Mailing Lists)"" wrote in message news:3339c510-be08-4426-9265-ba1965a9a...@networkmail.eu... > Hi Stan, > > Are you saving the instance of your c

Re: [PHP-DB] losing MySQL resource

2009-11-09 Thread Andy Shellam (Mailing Lists)
Hi Stan, Are you saving the instance of your class in $_SESSION? Class instances can be persisted across sessions, however resources (i.e. MySQL and other DB connections) cannot. What you need to do, is every method in your wrapper class that uses the MySQL resource needs to check if it's

Re: [PHP-DB] losing MySQL resource

2009-11-09 Thread Stan
I got as far as creating a class to be the wrapper ... instantiating an object of that class ... saving the reference in a $_SESSION variable ... but my object reference seems to be invalid upon the next request (in the same session) from the client browser. What have I missed? Thanks, Stan ""An

Re: [PHP-DB] losing MySQL resource

2009-11-09 Thread Andy Shellam (Mailing Lists)
Hi, I got around this by creating a database wrapper class which gets passed the credentials from the app's config file. An instance of the class is created and saved in the session, and every query to the database runs through the class's Query() wrapper method which checks if the conne

Re: [PHP-DB] losing MySQL resource

2009-11-09 Thread Stan
How do I make an Object persistant for the duration of a Session? Thanks, "Chris" wrote in message news:4ab6b16...@gmail.com... > Niel Archer wrote: > >> I'm maintaining a session. I successfully connect to a database ($DBConnect > >> = mysql_connect()). I save the connection resource in a sessi

Re: [PHP-DB] losing MySQL resource

2009-09-20 Thread Chris
Niel Archer wrote: I'm maintaining a session. I successfully connect to a database ($DBConnect = mysql_connect()). I save the connection resource in a session variable ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It remains valid while the user is on the current pag

Re: [PHP-DB] losing MySQL resource

2009-09-19 Thread Stan
Thanks. "Niel Archer" wrote in message news:20090919121842.b95b.a5cb2...@chance.now... > > I'm maintaining a session. I successfully connect to a database ($DBConnect > > = mysql_connect()). I save the connection resource in a session variable > > ($_SESSION['connection'] = $DBConnect) ... to u

Re: [PHP-DB] losing MySQL resource

2009-09-19 Thread Niel Archer
> I'm maintaining a session. I successfully connect to a database ($DBConnect > = mysql_connect()). I save the connection resource in a session variable > ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It > remains valid while the user is on the current page. > print_r(

[PHP-DB] losing MySQL resource

2009-09-19 Thread Stan
I'm maintaining a session. I successfully connect to a database ($DBConnect = mysql_connect()). I save the connection resource in a session variable ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It remains valid while the user is on the current page. print_r($_SESSION[