You are here: Re: [PHP] Having resource variables over several scripts « PHP « IT news, forums, messages
Re: [PHP] Having resource variables over several scripts

Posted by Benjamin Mack on 10/10/05 20:35

Hey,

actually, the key problem is that:
I installed this ssh2 extension and want to connect to e.g. a server,
and then, maybe on the next page, enter a command that will be executed
on that server and so on. I can't connect to a server everytime (or: i
COULD but I don't want to) because it takes a whole lot of time to do this.
http://www.php.net/manual/en/function.ssh2-connect.php
the connection I receive there is a resource.

Maybe I'll find a way with not exiting a script...

--
greetings,
benni.
-SDG-


Jeffrey Santos wrote:
> I was under the impression he was using the resource to get information then
> trying to pass that information... rereading it makes it seem otherwise, so
> sorry for the false information :-P I've never actually tried passing
> resources themselves among scripts so TG is most likely correct. As far as
> not exiting the script, that wouldn't seem very efficient and you might be
> better off just reaccessing the resources as needed.
>
> - Jeff
> -----Original Message-----
> From: tg-php@gryffyndevelopment.com [mailto:tg-php@gryffyndevelopment.com]
> Sent: Monday, October 10, 2005 1:10 PM
> To: php-general@lists.php.net
> Subject: RE: [PHP] Having resource variables over several scripts
>
> Ok, first let me disclaim that there are definitely a lot of people a lot
> smarter than me out there who may have figured this one out already, but as
> far as I know, resources like open file handles, database connection
> handles, objects, etc.. but especially anything that returns a resource
> number are not going to be carried over from one script execution to
> another.
>
> If I recall properly, lets say script1.php opens a file, that's resource #1,
> then it opens a database connection, that's resource #2, etc..
>
> Now let's say script2.php opens a database connection first, that's resource
> #1 for that script, then opens another database connection, that's resource
> #2, now it opens a file, that's resource #3..
>
> So the 'resource' number isn't tied to a certain type of handle (file, db
> connection, etc), it's based on the order of resources allocated.
>
> That's only semi-related to what you're talking about, but thought it was
> worth mentioning.
>
> But I believe all of these resources are freed up as soon as the script
> finishes executing thereby necessitating re-opening files, db connections,
> recreating objects, (maybe objects can be serialized, I forget) when the
> next script is executed. No carry-over possible.
>
>
> The solution? Don't exit the script. Unfortunately in an web environment
> you can't really keep a php script executing unless you create a php based
> server that your scripts connect to (doesn't have to be php based really..
> just any server that listens and can keep files open for as long as they're
> needed).
>
> Or maybe try to consolidate your file operations, in this case, so you can
> do it all in one pass. Don't open a file, read one little thing, close
> it... re-open it.. read something else... close it.. user makes changes..
> opens file again.. writes changes.. closes it. read once and write
> once.. See if you can streamline it somehow.
>
> Just some thoughts off the top of my head. Again, maybe someone else has a
> better answer, but I can't see how you'd avoid opening and closing each time
> unless you had a back-end server type program running.
>
> -TG
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация