Re: connection from one page to another
If you store an object in session it will be serialized and you "keep"
the same instance. But the database connection will be lost. When the
script exits at the end of the page it will clean up resources that are
not needed any more. Since HTTP is a stateless protocol you don't know
if the next page will open or not.
What you might want in your database class is something like:
public static function query ($qString)
{
if (!self::$dbConn) {
// If no SQL connection is established
self::connect();
}
|
A static class can also be useful since you (most likely) only use one
instance of the object.
|