it's my first time asking a question here, please bear with me as i'm just started coding not too long ago. A while ago, my colleague saw my code
$roles = new Roles();
foreach($roles->get as $role)
{
...irrelevant operation here
}
He commented that the way i put my query inside the iteration is wrong, i should change it to
$roles = $roles->get();
foreach($roles as $role)
He told me that if i put the query as an array expression in foreach loop, it would reference the database each loop, ultimately slowdown the whole site. I'd like to know whether it's true or not, and the logic behind it.