I have my query: ..
$di = FactoryDefault::getDefault();
$builder = $di->get('modelsManager')->createBuilder();
.... (Query builder)
$a_menu = builder ->getQuery()
->execute()->toArray();
the result:
array (size=67)
0 =>
array (size=9)
'menu_module_ok' => string '1' (length=1)
'menu_id' => string '2' (length=1)
'menu_super_id' => null
'menu_name' => string 'Administracion' (length=14)
'menu_type' => string 'ITEM' (length=4)
'menu_icon' => string 'icon-tasks' (length=10)
'menu_url' => string '#' (length=1)
'menu_option_key' => null
'menu_option_value' => null
1 =>
array (size=9)
'menu_module_ok' => string '1' (length=1)
'menu_id' => string '11' (length=2)
'menu_super_id' => string '20' (length=2)
'menu_name' => string 'Archivos' (length=8)
'menu_type' => string 'ITEM' (length=4)
'menu_icon' => string 'icon-th' (length=7)
'menu_url' => string '/private/file/index.html' (length=24)
'menu_option_key' => null
'menu_option_value' => null
2 =>
array (size=9)
'menu_module_ok' => string '1' (length=1)
'menu_id' => string '1' (length=1)
'menu_super_id' => null
'menu_name' => string 'Bienvenidos' (length=11)
'menu_type' => string 'ITEM' (length=4)
'menu_icon' => string 'icon-home' (length=9)
'menu_url' => string '/private/welcome/index.html' (length=27)
'menu_option_key' => null
'menu_option_value' => null
but if i want that the key must be a particular column:
$results = array();
foreach ($a_menu as $key => $row) {
$results[$row['menu_id']] = $row;
}
return $results;
The result:
array (size=67)
2 =>
array (size=9)
'menu_module_ok' => string '1' (length=1)
'menu_id' => string '2' (length=1)
'menu_super_id' => null
'menu_name' => string 'Administracion' (length=14)
'menu_type' => string 'ITEM' (length=4)
'menu_icon' => string 'icon-tasks' (length=10)
'menu_url' => string '#' (length=1)
'menu_option_key' => null
'menu_option_value' => null
11 =>
array (size=9)
'menu_module_ok' => string '1' (length=1)
'menu_id' => string '11' (length=2)
'menu_super_id' => string '20' (length=2)
'menu_name' => string 'Archivos' (length=8)
'menu_type' => string 'ITEM' (length=4)
'menu_icon' => string 'icon-th' (length=7)
'menu_url' => string '/private/file/index.html' (length=24)
'menu_option_key' => null
'menu_option_value' => null
1 =>
array (size=9)
'menu_module_ok' => string '1' (length=1)
'menu_id' => string '1' (length=1)
'menu_super_id' => null
'menu_name' => string 'Bienvenidos' (length=11)
'menu_type' => string 'ITEM' (length=4)
'menu_icon' => string 'icon-home' (length=9)
'menu_url' => string '/private/welcome/index.html' (length=27)
'menu_option_key' => null
'menu_option_value' => null
79 =>
array (size=9)
'menu_module_ok' => string '1' (length=1)
'menu_id' => string '79' (length=2)
'menu_super_id' => string '56' (length=2)
'menu_name' => string 'Buses' (length=5)
'menu_type' => string 'ITEM' (length=4)
'menu_icon' => string 'icon-home' (length=9)
'menu_url' => string '/management/bus/index.html' (length=26)
'menu_option_key' => null
'menu_option_value' => null
Associative array of rows by menu_id
there is other way to do this?