NYCPHP Meetup

NYPHP.org

[nycphp-talk] nested objects

Jeffrey Konikowski jkonikowski at nyc.rr.com
Tue Feb 11 08:15:56 EST 2003


In general, you can use classes within classes.  Can you give some more details how and where you instantiate the class? 
  
Something like: 
  
function get_data() { 
   $db = new db_class(); 
   ... 
} 
  
Or: 
  
$db = new db_class(); 
new_foo->get_data($db); 

-----Original Message----- 

Can I create an object that, in turn, creates another object within one of 
its functions? 

I have a db_class that accepts an SQL statement. It creates a connection 
thru ODBC and returns a recordset. I have a foo_class that (tries to) call 
the db_class to fill itself up. The main PHP page creates a new foo then 
does something like new_foo->get_data. 

Procedurally, it works. I did that to test the syntax and the ODBC call. 
But, when I nest the objects the db_class fails saying Unknown fucntion: 
odbc_exec. It *appears* that it does not have a valid conn_id. 

I probably didn't explain this well, but, I wanted to make sure I wasn't 
breaking any obvious rules before I posted examples. 

Am I on the right track? Thanks for any help. 
Michael 

_________________________________________________________________ 
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail 



--- Unsubscribe at http://nyphp.org/list/ --- 



More information about the talk mailing list