Update Record not Working

Hi,

I just don’t know what is going on here. I get no errors in the log files.

I have this code inside my controller:




$companyrecord = Company::find()

		->where(['id' => $session['company_id']])

		->one();

$companyrecord->pay_count = 300;

$companyrecord->save();



When I do this before the save() it show the correct information with the value set to 300:


var_dump($companyrecord);

But then doing this:


var_dump($companyrecord->save());

It shows false.

I am forcing the value of the column to 300, but it does nothing. The default is set to start at 1 and every time I run this code, it stays at 1, it never gets set to 300.

Any ideas?

Hi,

if method save() return false. Try this




if (!$companyrecord->save()) {

   var_dump($companyrecord->getErrors());

}



Thank you, that showed me the error and I was able to fix it.