How to Return Message for an incomplete validation and more...

Hi,

I’m new to this forum and yii framework. I know this is very basic but I don’t seem to understand how this should work. Point me to a thread that answers this is okay by me.

Database with a relationship, logging – should have an existing id in loggers.

When I create a logging record and input an ID that is not present in loggers, a CDbException is displayed. How do I prevent this and just inform the logger that the id is non-existent…

Also it would help if I know which methods are involved and what do I need to put in each method to make this work.

Thanks,


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 

These are main topics you’d better to start with if you whant to customise your error messageshttp://www.yiiframework.com/doc/guide/1.1/en/topics.error

http://www.yiiframework.com/doc/guide/1.1/en/basics.entry#debug-mode

http://www.yiiframework.com/doc/api/1.1/CWebUser#setFlash-detail

Also, you may add custom validation rule to catch the error at $model->validate() stage. (error message will be in $model->errors then) Examples