I was told that database request make in loop (foreach) is bad, but how can I do other way this request:
$k1 = ORM::for_table('k1')->find_many();
foreach($k1 as $k){
$k2 = ORM::for_table('k2')->where('id', $k->id)->find_one();
echo $k2->name;
}
Using the
joinyou can create the same query without use a loop.Edit after the comment:
Previous answer: