php - Generating hirarchical structure out of a flat table -
main question: efficient way transform flat table tree hierarchical structure ?
context: bit rusted , don't know if should handled on sql, php or javascript (kendo ui) side !
for kendo treeview (hierachicaldatasource), must export json encoded tree structure table made single select multiple joins multiple tables... generates huge table of following logical structure:
goal group "date", "client", "employee" , list "events". need structure one:
guess best series of php loops ?... code ?
thanks !
try php code:
$result = array(); foreach($data $row) { $date = $row['date']; $employee = $row['employee']; $client = $row['client']; $event = $row['event']; $result[$date][$client][$employee][] = $event; }
i suppose $data
through simple query before code.
Comments
Post a Comment