Home  >  Article  >  Backend Development  >  yii CDbException,该如何解决

yii CDbException,该如何解决

WBOY
WBOYOriginal
2016-06-13 13:00:42979browse

yii CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`blog`.`articles`, CONSTRAINT `fk_articles_users` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION). The SQL statement executed was: INSERT INTO `articles` (`viewNum`, `commentNum`, `categoryId`, `title`, `content`, `statusId`, `tagId`, `createdTime`, `userId`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8). Bound with :yp0=0, :yp1=0, :yp2=1, :yp3='1', :yp4='1', :yp5=2, :yp6=1, :yp7=2012, :yp8=0
------解决方案--------------------
字面来看是外键约束错误,你看看是不是数据内容填写的时候重复了,或者外键引用的实体已经不存在了!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn