Please Bond give an idea how to aproach this.
Sql
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL auto_increment,
`category` varchar(100) NOT NULL,
`pid` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `pid` (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `categories`
--
--
-- Constraints for dumped tables
--
--
-- Constraints for table `categories`
--
ALTER TABLE `categories`
ADD CONSTRAINT `categories_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `categories` (`id`);
array:
Array
(
[0] => Array
(
[Items for Sale] => Array
(
[0] => Array
(
[Antiques & Collectibles] => Array
(
[0] => Advertising
[1] => Animation & Cartoons
[2] => Appliances
[3] => Autographs
[4] => Autos & Vehicle Memorabilia
[5] => Cigarette & Tobacco Paraphernalia »
[6] => Clocks »
[7] => Coins & Currency
[8] => Comics »
[9] => Dolls »
[10] => Entertainment Memorabilia »
[11] => Food & Beverage
[12] => Furniture
[13] => Groups & Cultures
etc...
i want this array to insert in that table to have this categories recurisively. i try something like this
foreach ($categories100 as $key => $value) {
foreach ($value as $key1 => $value1) {
$categorii = new Category();
$categorii->setCategory($key1);
foreach ($value1 as $key2 => $value2) {
foreach ($value2 as $key3 => $value3) {
$subcategorii = new Category();
$categorii->associateCategory($categorii);
$subcategorii->setCategory($key2);
}
}
//print_r($categorii);
}
}
but it says that: The table categories is not in a *-to-manyrelationship with the table categories. but how u say i setted foreig key reference itself.
Array
(
[one-to-one] => Array
(
)
[many-to-one] => Array
(
[0] => Array
(
[table] => categories
[column] => pid
[related_table] => categories
[related_column] => id
)
)
[one-to-many] => Array
(
[0] => Array
(
[table] => categories
[column] => id
[related_table] => categories
[related_column] => pid
[on_delete] => no_action
[on_update] => no_action
)
)
[many-to-many] => Array
(
)
)