Jochem,

Thanks so much for your advice.

In the end, I managed to find why that little EZSql tool wasn't working for me, 
and thus what I'm *really* putting into the session variable is an array. 

I understand also that each user would get a copy of the same session 
variables, but this is for a small antique dealer and there will only ever be 
one or two people using the admin screen which started this mess in the first 
place.

Also, I'm using the auto_prepend_file to simulate the CF concept of an 
application.cfm which gets included at the start of every page. I've configured 
it such that if the include file doesn't exist in the application's directory, 
it then goes and gets an empty file of the same name to prepend from the 
default include path... pretty neat, actually.

When you said:

    "...the strength and simplicity of PHP stem from the decision to make/keep
    PHP a 'share nothing'  architecture."

What did you mean, by that? I've not heard of this "share nothing" idea. What 
is the idea of "share nothing" and why is it a strength? I'd like to understand 
so if I'm doing something ass-backwards (read: inefficiently), that I can 
change what I'm doing.

So far, things seem to be working for me, but perhaps there's an easier way to 
accomplish some of the stuff I'm doing, you know?

I'd appreciate any time you could spend answering my questions.

Thanks,
Chris

Jochem Maas <[EMAIL PROTECTED]> wrote: CF has an application scope - PHP does 
not.
the strength and simplicity of PHP stem from the decision to make/keep
PHP a "share nothing" architecture.

with regard to shoving stuff in the SESSION superglobal:

1. it not shared between requests by different users - meaning
that the SQL query you gave as an exmaple would still be run once
by every visitor and each visitor would have a copy of the
result set object.

2. performance-wise sticking objects in the session is possibly
something to be avoided is possible - storage and retrieval of 'complex'
structure (i.e. objects in this case) comes with a certain performance
penalty (you might want to consider using an array to store the query results)

3. you MUST load the class definitions of ALL the objects that are in your 
session
BEFORE you start the session.

Christopher Jordan wrote:
> Hi folks,
>   
>  I'm a ColdFusion  developer,  but I'm branching out into  PHP because alot 
> of  my smaller clients don't want to pay for CF.
>   
>   Anyway, a bit of background:
>   
>   I've got a page that does a search on one of my tables. I'm using  Justin 
> Vincent's ezSQL (http://php.justinvincent.com) to fetch the  result set into 
> an object that can be referenced nicely. Here's what  his example code looks 
> like:
>   
>           // Select multiple records from the database and print them out..
>           $users = $db->get_results("SELECT name, email FROM users");
>           foreach ( $users as $user ){
>                        //  Access data using object syntax
>                       echo $user->name;
>                       echo $user->email;
>           }
>   
>   So far so good. So I've got an iframe on the page which (I hope) will  
> eventually display the results of the search. The user will then click  on 
> the search result for which they want to view the details, and the  
> information from that row will be populated inside the main page (the  one 
> that houses the iframe).
>   
>   Hope that makes sense. 
>   
>   Okay, so my trouble is that I don't know how to enable the page inside  the 
> iframe to have access to the result object created by Justin  Vincent's nifty 
> little class. In CF I can just say:
>   
>      session.oResults = queryname
>   
>   CF automatically returns any query as an object with the name of the  query 
> as the object name (i.e. queryname.MyIdField, or  queryname.EmployeeNumber, 
> etc.) Using a line like the one above  (assigning the query object to a 
> session variable) all of my subsequent  requests would have access to that 
> result set simply by using the  object.
>   
>   I'm *sure* there's a way to do this in PHP. I'm just falling short of 
> finding the answer. I've tried:
>   
>       $_SESSION["SearchResult"] = $db->get_results($query);
>   
>   But it doesn't seem to work. I may have some other problem using the 
> object. I just re-read my error and it says:
>   
>   Fatal error: Call to a member function get_results() on a non-object in 
> inventorymanager.php on line   93
>   
>   hmm... I sure would appreciate a little guidence here. Even if my  problem 
> is with the way I'm using the object, is the idea of assigning  that object 
> to the session scope the right way to do this or is there a  better approach. 
> To that end, I suppose I'm looking for an idea of the  best practice.
>   
>   Thanks!
>   Christopher Jordan
>   Planet Access
>   Arlington, TX
>   
> 
>    
> ---------------------------------
> Yahoo! Shopping
>  Find Great Deals on Holiday Gifts at Yahoo! Shopping 




                        
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

Reply via email to