| Justin Patrin 2005-07-24, 8:39 pm |
| On 7/21/05, Tom Rogie <Tom@rogie.be> wrote:
> Hello,
>=20
> For a project with lots of database access, I planned to put the
> DB:connect object into a session.
>=20
> I only have one problem: before I start the session, the classes from
> the project must be defined _and_ also the DB object must be connected (
> DB::connect( $db ) ) else I get PHP incomplete class object errors.
> So I cannot check the isset of my $_SESSION["db"] variable before I do
> connect to the database... Means that I have to connect to the database
> on every click?
>=20
> Is there a way to keep using the same database object through the session=
?
>=20
Storing a DB object in a session won't work. The connection to the
database is a special kind of variable called a "resource". Same as
for writing to and reading from files and sockets. You can't put these
in a session as once the request is finished the resource is closed.
You'll need to do a DB::connect on every request.
--=20
Justin Patrin
|