I do not like using this kind of iteration of db results like this (news items in the db):
Code: Select all
while ($row = $rs->nextRow())
{
echo $row['headline'];
echo $row['body'];
}
I would prefer putting all news items as objects in an array and then iterate over them like this:
Code: Select all
foreach ($items as $item)
{
echo $item->getName();
echo $item->getBody();
}
For me this would be more convenient, as I may also need to do some tricks with the data in the news item object (for example, do some replacing or any other string manipulation).
Is it ok to use object arrays? What if I have 500 objects in the array? Can this method become a performance hit?