|
Posted by floortje4 on 11/13/07 14:05
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.
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;
}
Navigation:
[Reply to this message]
|