php - Math operation in yii 2 Active Query -


is there way subtract value in int column 1?i have button when clicked call function save data in table want know how subtracting number in database using yii 2 have tried following code below had no effect. can me how make math operations in yii 2?

public static function addsubject($subjectid, $clientid){     $subject = activecurriculum::findone(['subjectid' => $subjectid]);      $activesubject = new activesubject();     $activesubject->clientid = $clientid;     $activesubject->subjectid = $subject->subjectid;     $activesubject->subjectcode = $subject->subjectcode;     $activesubject->days = $subject->days;     $activesubject->time = $subject->time;     $activesubject->section = $subject->section;     $activesubject->room = $subject->room;     $activesubject->units = $subject->units;     $subject->units = $subject->units - 1; //this should subtract number      //of slots 1 not working.     $activesubject->save();      return true;      //return static::findone(['subjectid' => $subjectid]);                 //->where(['subjectid' => $subjectid]);    } 

when made changes in ar object , want changes saved should execute ->save():

$subject->units = $subject->units - 1;  $subject->save(); 

looks forgot that.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -