On Wed, Jun 05, 2002 at 10:32:39PM +0100, Henry Blackman wrote: > Do I create a new document and pass the primary key as it's a variable in > the > > $document = new Document(number); > > and have the constructor retrieve the appropriate data from MySQL and fill > the attribute variables. > > Or do I do something like: > > $document = new Document; > $document ->retrieve(number); > > Which is the best and most "valid" way of doing things.
You could do both, and use whatever you find more appropriate at that moment: class Document { function Document($id='') { if($id) { $this->retrieve($id); } } function retrieve($id) { //do something } } BTW I get the feeling that you want retrieve() to output directly to the browser (echo/print...), IMHO you shouldn't do that at all but let retrieve() return a string/array/whatever. But that's up to you :) -- Daniel Tryba -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php