Created
May 24, 2012 06:56
-
-
Save ssmusoke/2779910 to your computer and use it in GitHub Desktop.
Category Table and Data with foreign key on root plus exception got
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`gandaancestry`.`category`, CONSTRAINT `fk_category_root` FOREIGN KEY (`root`) REFERENCES `category` (`id`) ON DELETE SET NULL ON UPDATE SET NULL)' in D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\DBAL\Statement.php:131 Stack trace: #0 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\DBAL\Statement.php(131): PDOStatement->execute(NULL) #1 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\ORM\Persisters\BasicEntityPersister.php(239): Doctrine\DBAL\Statement->execute() #2 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\ORM\UnitOfWork.php(896): Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts() #3 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\ORM\UnitOfWork.php(304): Doctrine\ORM\UnitOfWork->executeInserts(Object(Doctrine\ORM\Mapping\ClassMetadata)) #4 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\ORM\EntityManager.php(355): Doctrine\ORM\UnitOfWork->commit(NULL) #5 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\application\views\scripts\index\index.phtml(40): Doctrine\ORM\EntityManager->flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- phpMyAdmin SQL Dump | |
-- version 3.3.9 | |
-- http://www.phpmyadmin.net | |
-- | |
-- Host: localhost | |
-- Generation Time: May 23, 2012 at 03:38 PM | |
-- Server version: 5.1.41 | |
-- PHP Version: 5.3.5 | |
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; | |
-- | |
-- Database: `gandaancestry` | |
-- | |
-- -------------------------------------------------------- | |
-- | |
-- Table structure for table `category` | |
-- | |
DROP TABLE IF EXISTS `category`; | |
CREATE TABLE `category` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`title` varchar(64) NOT NULL, | |
`lvl` int(11) unsigned DEFAULT NULL, | |
`lft` int(11) unsigned DEFAULT NULL, | |
`rgt` int(11) unsigned DEFAULT NULL, | |
`root` int(11) unsigned DEFAULT NULL, | |
`parent_id` int(11) unsigned DEFAULT NULL, | |
PRIMARY KEY (`id`), | |
KEY `fk_category_parent` (`parent_id`), | |
KEY `fk_category_root` (`root`), | |
CONSTRAINT `fk_category_root` FOREIGN KEY (`root`) REFERENCES `category` (`id`) ON DELETE SET NULL ON UPDATE SET NULL, | |
CONSTRAINT `fk_category_parent` FOREIGN KEY (`parent_id`) REFERENCES `category` (`id`) ON DELETE SET NULL ON UPDATE SET NULL | |
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; | |
-- | |
-- Dumping data for table `category` | |
-- | |
INSERT INTO `category` (`id`, `title`, `lvl`, `lft`, `rgt`, `root`, `parent_id`) VALUES | |
(6, 'Food', 0, 1, 8, 6, NULL), | |
(7, 'Fruits', 1, 2, 3, 6, 6), | |
(8, 'Vegetables', 1, 4, 7, 6, 6), | |
(9, 'Carrots', 2, 5, 6, 6, 8); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment