I can insert() but not update()

Yii 1.1.17

mysql

[color="#FF0000"]It shows that the save() when executed properly to update a model. No error, no validation error, return true… nothing… the record is intact, it was never updated.[/color]

It was working for years but for some reason, it’s stop updating models.

This problem only occur in FEW PARTICULAR ACTIONS. When I try the save() operation anywhere else it works without problem.




public function actionEditExtraCharge( $id )

{

$extraCharge = TENANT_ExtraCharge::model()->findByPk( $id );

if( isset($extraCharge) )

{

    if( isset($_POST["TENANT_ExtraCharge"]) )

    {

        $extraCharge->attributes = $_POST["TENANT_ExtraCharge"];      

        $extraCharge->save(false);   

    }

    $this->render( "editExtraCharge", [ "extraCharge" => $extraCharge,

} else {

    throw new CHttpException(500, "Cannot find the record: " . $id);

}

}



[color="#0000FF"]

[list=1]

[*] When I dump $extraCharge->getErrors() after save() I get an empty array (NO VALIDATION ERROR);

[*] I checked for any overwrite of beforeSave() or beforeValidate()… there’s NONE

[*] When I try to force an $extraCharge->insert() it will work or save() with a new record it will work.

[*] If I try to force an $extraCharge->update() or $extraCharge->updateByPk($extraCharge->getOldPrimaryKey(),$extraCharge->getAttributes()); It will NOT WORK.

[*] I only have this problem with only 2 models TENANT_ExtraCharge and TENANT_MainCat… I have commented any non-vital functions, but still…

[/list][/color]

I’ve been searching this problem for 3 days now… I’m about to jump through the fuc***g window.

ANY suggestion is welcome.

Thank you for your time.

In those 3 days, have you done any debugging?

I don’t get it, you mean with logs or monitor mysql for incoming queries? Yes to both.

I check all the standard cause for this problem but nothing

No I mean in your IDE, simple step-through.

Yes. Any constructive suggestion is welcome

If save(false) is the actual code, be aware that no validation is performed.

http://www.yiiframework.com/doc/api/1.1/CActiveRecord#save-detail.