by wvenable · 16y ago · 0 comments
$result = $conn->execute('select * from favcolor order by color, name');
while($row = $result->next()) {
if ($result->groupBeginning('color')) {
echo $row['color'].': '.$row['name'];
} else {
echo ', '.$row['name'];
}
if ($result->groupEnding('color')) echo "\n";
}
echo 'Count:'.$result->count();
I just came up that off the top of my head, but there's nothing impossible in there. Also, instead of field name for groupBeginning(), passing a closure would also be possible. echo $conn->execute('select * from favcolor order by color, name')
->groupBy(L(val)->color)
->map(L(key)->wrap('<li><b>', '</b>')
->append(
': ',
L(val)->map(L(val)->name)->join(','),
'</li>'))
->join("\n");Also http://commonphp.blogspot.com is where I write about it.