NYCPHP Meetup

NYPHP.org

[nycphp-talk] Object Oriented Question

ophir prusak prutwo at onebox.com
Fri Jun 7 13:50:38 EDT 2002


This was not supposed to go to the whole list.
my apologies.

----
Ophir Prusak
Internet developer 
prutwo at onebox.com | http://www.prusak.com/ 



---- "ophir prusak" <prutwo at onebox.com> wrote:
> thanx for the code.
> 
> That's what I currently have more or less.
> My questions was really - does it make sense to create a game object
> for every result returned from a sql query ?
> 
> I'm currently leaning towards no - despite what charles said - especialy
> for PHP (though Java might be a different story).
> 
> Any more thoughts about helping me do the work for StationPlay or maybe
> even starting vgsp.com from scratch with me - http://www.consolemonkey.com/twiki/bin/view.cgi/Stationplay/VideoGameStartingPoint
> 
> write back
> ophir
> 
> ----
> Ophir Prusak
> Internet developer 
> prutwo at onebox.com | http://www.prusak.com/ 
> 
> 
> 
> ---- "Ian Forsyth" <ian at plusfour.org> wrote:
> > 
> > class game extends db //in teh db class you have a function db that
> > intialized connection so there is only on file with connection credentials..
> > {
> > 	function game($gameid,$type = "single")
> > 	{
> > 		switch($gameid)
> > {
> > 	case "0" :
> > 	$this->getAllGames($type);
> > 	break;
> > 	default :
> > 	$this->getGame($gameid);
> > }
> > 	function getAllGames($type)
> > {
> > 	$q = "select * from games g,reviews r where g.gameid = r.gameid
> > ";
> > 	$q .= " and g.console = '$type'";
> > 	$this->query($q);
> > }
> > }
> > 
> > > -----Original Message-----
> > > From: ophir prusak [mailto:prutwo at onebox.com]
> > > Sent: Friday, June 07, 2002 10:48 AM
> > > To: NYPHP Talk
> > > Subject: [nycphp-talk] Object Oriented Question
> > >
> > >
> > >
> > > Hi All,
> > >
> > > I've decided to clean up the code on my site, and at the same time
> > use
> > > object oriented code.
> > > I have a few ideas in my head, but I really wanted to get some
> input
> > > from others that have built projects in PHP using OO code.
> > >
> > > Here's the problem I'm currently trying to solve (I've simplified
> > it
> > > a bit and left out un-necessary details).
> > > My site is a video game site. Currently, my database has:
> > > A games table which has basic game information for each game (game_id,
> > > title, console, etc)
> > > A reviews table which has game_id (foreign key to games table),
> review
> > > date, review text, reviewer name and email.
> > >
> > > If you look at this URL
> > > http://ps2.consolemonkey.com/reviews_date.php3?order=rev_id
> > > you can see a page which shows a list of all the games and the
> date
> > for
> > > the most recent review for that game.
> > >
> > > Currently I'm just doing this with a single SQL query (simple join
> > of
> > > the two tables) and echoing out the results.
> > > Very fast.
> > >
> > > I'm trying to envision how to create this page using object oriented
> > > code.
> > > My initial thought was to somehow use a game object, but if I have
> > to
> > > instantiate a game object for every game, this seems like it would
> > have
> > > an enormous amount of overhead and be slow.
> > >
> > > How is this usually done on OO projects ?
> > >
> > > Am I missing something or would you say that if your data sits
> in
> > > a relational
> > > database and your doing a search or mass listing of data then OO
> > code
> > > is not the way to go.
> > >
> > > comments/suggestions/thoughts/ideas/etc ?
> > >
> > > Thanx
> > > Ophir
> > >
> > >
> > > ----
> > > Ophir Prusak
> > > Internet developer
> > > prutwo at onebox.com | http://www.prusak.com/
> > >
> > >
> > >
> > >
> > 
> > 
> >  
>  



More information about the talk mailing list