Heim  >  Artikel  >  Backend-Entwicklung  >  yii CDbException,该如何解决

yii CDbException,该如何解决

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

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
------解决方案--------------------
字面来看是外键约束错误,你看看是不是数据内容填写的时候重复了,或者外键引用的实体已经不存在了!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn