Open
Description
Data before:
CREATE TABLE IF NOT EXISTS `Menu` (
`id` int(10) NOT NULL,
`lft` int(11) NOT NULL,
`rgt` int(11) NOT NULL,
`depth` int(11) NOT NULL,
`active` tinyint(1) DEFAULT '1',
`name` varchar(50) NOT NULL,
`url` varchar(100) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
INSERT INTO `Menu` (`id`, `lft`, `rgt`, `depth`, `active`, `name`, `url`) VALUES
(1, 1, 8, 0, 1, 'Root', NULL),
(2, 3, 4, 2, 1, 'Node 1-1', NULL),
(3, 2, 5, 1, 1, 'Node 1', NULL),
(5, 6, 7, 1, 1, 'Node 2', NULL);
Moving code:
$model = Menu::findOne(2);
$target = Menu::findOne(5);
$model->insertAfter($target);
$model->insertBefore($target);
Data after:
id lft rgt depth active name url
1 1 8 0 1 Root NULL
3 2 4 1 1 Node 1 NULL
5 4 5 1 1 Node 2 NULL
2 6 7 1 1 Node 1-1 NULL
On 'Node 1' (id:3) there are wrong 'rgt' value
Metadata
Metadata
Assignees
Labels
No labels