connection from one page to another

This is a discussion on connection from one page to another within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi I have a class that is my interface to mysql. I create an instance og class an connect to ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-05-2005
gachsaran
 
Posts: n/a
Default connection from one page to another

Hi

I have a class that is my interface to mysql. I create an instance og
class an connect to db. Then i change to another page and want to use
the same instace of class. How can i send an object (the instance) to
another page ?


Any help will be appricated.
Gachsaran
Reply With Quote
  #2 (permalink)  
Old 12-06-2005
Dennis Ålund
 
Posts: n/a
Default 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.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:59 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0