Hello,
I need to create an array that contain all elements organized by a tree of parents and childs
Heres my table:
CREATE TABLE IF NOT EXISTS `menu` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`active` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT 'Menu visibility',
`menutypeid` int(10) unsigned NOT NULL,
[b]`parentid` int(10) unsigned DEFAULT NULL,[/b]
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Name or title',
`alias` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Unique identifier',
`link` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Display or navigation link',
`tbicon` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Twitter Boostrap class icon',
`image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Image to display with menu name',
`order` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Show relative order',
PRIMARY KEY (`id`),
KEY `order` (`order`),
KEY `active` (`active`),
KEY `parentid` (`parentid`),
KEY `menutypeid` (`menutypeid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
for example:
Now im stuck on it, Note: it can have more levels, unlimited in that case
Also im not using AR design because performance and speed. im getting all rows from database at once.
Any ideia to do that easy?
Thanks