Greetings to all.
Yii is my first framework, i’ve started to study it two weeks ago.
And recently i’ve faced the problem, that I can’t solve.
Let us assume that there is a MySQL table table
with the composite index id_1
, id_2
and the third field value
. And there is an AR-model Table
.
I have to change value
field of the record with given index through AJAX. I don’t use integrated AJAX-handlers and develop my own with JQuery.
So, the function, that changes the value, looks like:
// i find the desired record
$model = Table::model()->findByAttributes(array(
'id_1' => $id_1,
'id_2' => $id_2,
));
// change it's value
$model->value = 'VALUE';
// save it and print the result
if($model->save()) {
exit('1');
}
else {
exit('0');
}
Before saving the value there is no problems. Also, i’ve tried to launch
$model->validate();
and there were no problems with it.
But when this method starts:
$model->save();
the Exception
throws.
And I do not understand, what’s the problem. May be I’m too tired to think brightly, but, really, what’s going on?
Could anybody explain me?
PS: Creating of new records of this model is fine (without AJAX), and other models are good too. I suppose that AJAX making it impossible to save the record, but it’s just an intuition, not a strong explanation.
Thanks for help ahead of time,
and excuse my English.