Hi everyone. am a new bee to yii framework
I have created two tables with two primary keys and one foreign key (reference of first table) and when I applied gii crud to those tables first one with out fk is ok . But the problem is if the id (10 eg) is not there in first table and trying add the non existing value(eg 10) in referencing table its giving error. I know the error is unless we dont have entries in main table we can enter the values in another table. When I apply crud operations using gii am getting error.
I want to know that how to handle that error.
Regards
Shaik
Page 1 of 1
primary and foreign key in yii foreign key validations in yii gii crud
#3
Posted 14 August 2012 - 07:57 AM
I am getting this year when I try to add a group id of which is not there in first table(primary key).
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 (`testyiiapp`.`explanationcontent`, CONSTRAINT `explanationcontent_ibfk_1` FOREIGN KEY (`groupid`) REFERENCES `explanationmaster` (`id`)). The SQL statement executed was: UPDATE `explanationcontent` SET `id`=:yp0, `groupid`=:yp1, `sequence`=:yp2, `exp_text`=:yp3 WHERE `explanationcontent`.`id`=8
Regards
Shaik
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 (`testyiiapp`.`explanationcontent`, CONSTRAINT `explanationcontent_ibfk_1` FOREIGN KEY (`groupid`) REFERENCES `explanationmaster` (`id`)). The SQL statement executed was: UPDATE `explanationcontent` SET `id`=:yp0, `groupid`=:yp1, `sequence`=:yp2, `exp_text`=:yp3 WHERE `explanationcontent`.`id`=8
Regards
Shaik
#4
Posted 01 February 2013 - 06:53 AM
Hello everybody,
I am beginner in yii framework.
I need help for implementing relationship between table in yii please give me the solution using example.
I am beginner in yii framework.
I need help for implementing relationship between table in yii please give me the solution using example.
#5
Posted 01 February 2013 - 09:08 AM
shaik did you try this command in phpmyadmin or something like this ?
@sunny welcome to forum, two links for You:
first to read:
http://www.yiiframew...en/database.arr
http://www.yiiframew..._many-relation/
@sunny welcome to forum, two links for You:
first to read:
http://www.yiiframew...en/database.arr
http://www.yiiframew..._many-relation/
#6
Posted 01 February 2013 - 09:47 AM
shaik, on 14 August 2012 - 07:57 AM, said:
I am getting this year when I try to add a group id of which is not there in first table(primary key).
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 (`testyiiapp`.`explanationcontent`, CONSTRAINT `explanationcontent_ibfk_1` FOREIGN KEY (`groupid`) REFERENCES `explanationmaster` (`id`)). The SQL statement executed was: UPDATE `explanationcontent` SET `id`=:yp0, `groupid`=:yp1, `sequence`=:yp2, `exp_text`=:yp3 WHERE `explanationcontent`.`id`=8
Regards
Shaik
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 (`testyiiapp`.`explanationcontent`, CONSTRAINT `explanationcontent_ibfk_1` FOREIGN KEY (`groupid`) REFERENCES `explanationmaster` (`id`)). The SQL statement executed was: UPDATE `explanationcontent` SET `id`=:yp0, `groupid`=:yp1, `sequence`=:yp2, `exp_text`=:yp3 WHERE `explanationcontent`.`id`=8
Regards
Shaik
Hi Shaikh,
you are trying to insert into your child table when u dont have related entry in your parent table. try to insert that parent id in your parent table. then you can add the same key id in your child table.
#7
Posted 01 February 2013 - 09:51 AM
sunny lalwani, on 01 February 2013 - 06:53 AM, said:
Hello everybody,
I am beginner in yii framework.
I need help for implementing relationship between table in yii please give me the solution using example.
I am beginner in yii framework.
I need help for implementing relationship between table in yii please give me the solution using example.
Hi Sunny,
Welcome to Yii Family. if you can tell us what you want to achieve..that'd be easy for someone to help you..
however find this link it helps..
http://www.yiiframew...s-for-newcomer/
http://www.yiiframew...ry-with-through
cheers!!
Share this topic:
Page 1 of 1

Help













