Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2343
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Preserving an object |
| Date | 2011-06-25 13:10 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <iu54pt$jbb$1@dont-email.me> (permalink) |
| References | <fac5cb7c-2af6-4468-85ac-57067de9b2ca@q15g2000yqk.googlegroups.com> <iu464v$8sv$1@news.albasani.net> <a3c0f9cc-3b28-4546-9972-0e19a8755b4c@g16g2000yqg.googlegroups.com> <iu4j48$2h6$1@dont-email.me> <d4c69c3f-37b6-4c06-bcd5-f25e543e2548@16g2000yqy.googlegroups.com> |
On 6/25/2011 9:37 AM, bruceaj wrote:
> On Jun 25, 8:08 am, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 6/25/2011 7:06 AM, Jivanmukta wrote:
>>
>>>> Put it in a separate file and include it?
>>
>>> IMHO it is not enough. Object should be stored in $_SESSION.
>>
>> Don't worry about TNP - it's a typical response from him. He doesn't
>> even know the difference between a class and an object.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> I have similar problem.
>>> I tried to solve it this way:
>>> File 1:
>>> session_start();
>>> ...
>>> $_SESSION['statement'] = $statement; // object
>>
>>> File 2:
>>> session_start();
>>> function __autoload($className) {
>>> require_once 'class.' . strtolower($className) . '.php';
>>> }
>>> $statement = $_SESSION['statement'];
>>
>>> but I receive such error:
>>
>>> object (__PHP_Incomplete_class) #1 (8) {
>>> ["__PHP_Incomplete_Class_Name"] => string(9) "Statement" etc.
>>
>>> Could anybody help me?
>>
>> You have to have the class file loaded BEFORE starting the session so
>> the interpreter knows how to deserialize the $_SESSION object.
>>
>> P.S. I don't like autoload. It causes too many problems, like
>> performance from having to search multiple directories, or even loading
>> the wrong file because someone stuck a file with the same name in
>> another directory. Even changing directory permissions can cause problems.
>>
>> And, as you see, it doesn't work with sessions.
>>
>
> Well, the object I'm trying to preserve is a database connection. SO,
> from reading the above responses, it SEEMS that $_SESSIONs will NOT
> work. Bottom line, I can't do it.
>
> Thanks for the responses....
>
> Bruce
No. Database connections are closed when the script terminates.
Transactional programming, like for web page scripts, is much different
than non-transactional programming. Basically you can pass data from
one script to another, but you cannot pass any external resources.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Preserving an object bruceaj <bruceaj@bellsouth.net> - 2011-06-24 19:45 -0700
Re: Preserving an object The Natural Philosopher <tnp@invalid.invalid> - 2011-06-25 09:27 +0100
Re: Preserving an object Jivanmukta <jivanmukta@poczta.onet.pl> - 2011-06-25 04:06 -0700
Re: Preserving an object Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-25 08:08 -0400
Re: Preserving an object bruceaj <bruceaj@bellsouth.net> - 2011-06-25 06:37 -0700
Re: Preserving an object Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-25 13:10 -0400
Re: Preserving an object The Natural Philosopher <tnp@invalid.invalid> - 2011-06-26 04:18 +0100
Re: Preserving an object Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-25 08:02 -0400
csiph-web