Reply to Re: Objects or not ?

Your name:

Reply:


Posted by Jerry Stuckle on 11/13/07 14:13

floortje4@gmail.com wrote:
> On 13 nov, 14:40, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
> Hi Jerry,
>
>> First of all, don't do the select in your code. Let your objects do it.
>
> Yup just trying to make the point without producing tons of code :-)
>
>> In this case, create a userlist class and let it perform the select
>> statement, building a new userobject for each row.
>
> Maybe I dont understand you but is what im trying to avoid. Lets say
> $aData contains 1000 rows with unique UserId's. Then this code would
> produce 1001 select queries.
>

But what you should be avoiding is having to worry about stuff like this
in your code. OO programming is all about abstracting the details.

> function CreateUserObj()
> {
> $aData=$db::select('SELECT UserId FROM forum');
>
> foreach ($aData as $val)
> {
> // executes a new select statement
> $aUserObj[$val['UserId']]=new User($val['UserId']);
> }
>
> return $aUserObj;
> }
>
>

No, this is one query, and you retrieve multiple rows from that query.

But if you need 1000 rows, you need to retrieve all 1000 rows somehow.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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