2011-07-09 16:07:12 1 评论 Yii 1.0 Boy.Lee

获得Yii 1.0框架 Active Record 中的错误

{Boy Said}

What about when you called $arClass->save(), then nothing insert into DB, no error show? We can call a property of AR to show the error messages, then we know what's wrong.

{Code}

 //record Reequtaion
$newReEquation = new Reequation();
$newReEquation->uid = Yii::app()->user->id;
$newReEquation->first = $newEquation->first;
$newReEquation->operator = $newEquation->operator;
 $newReEquation->second = $newEquation->second;

$newReEquation->save();//save
print_r($newReEquation->errors); //display error messages after save()