Hello! At the begening I apologize for my English that is on th weak level but I wish You can understand my question. I have table:
CREATE TABLE IF NOT EXISTS `ShopCategory` (
`ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
`parentID` int(11) unsigned DEFAULT NULL,
`description` text,
`status` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
KEY `parentID` (`parentID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Model:
public function initialize()
{
$this->setSource("ShopCategory");
$this->hasMany('ID', 'ShopCategory', 'parentID', array('alias' => 'categories'));
$this->belongsTo('parentID', 'ShopCategory', 'ID', array('alias' => 'ShopCategory'));
}
I need to get all records in format:
<ul>
<li>processors
<ul>
<li>AMD</li>
<li>Intel
<ul>
<li>i5</li>
<li>i7</li>
</ul>
</li>
</ul>
</li>
</ul>
Thats all are categories (Processors, ADM, Intel, i5, i7);
I tried do all day but i can't write function to do that. I'll be very grateful for help.