Hi all,
I need to save records in the database from an asyncronous request. So I wrote this piece of code:
parse_str($_POST['form'], $form);
$id = $_POST['id'];
$test = Test::model()->findByPk($id);
if($test === null)
throw new CHttpException(404, 'Test not found');
print_r($test);
$test->attributes = $form['Test'];
if(isset($form['HoseConfiguration']))
{
$r = true;
foreach($form['HoseConfiguration'] as $k=>$h)
{
$hose = $test->hoses[$k];
$hose->attributes = $h;
$s = $hose->save();
}
}
if (!$test->save())
echo 'error';
else
echo 'ok';
I did put the print_r in order to debug, because the record is not saved in the db, but actually it does return ‘ok’, and on the next call I can see the modified values inside the object properties.
Any explanation?
thanks a lot