can directly modify model?

Whenever you modify the record, the first query. $ rebot = Rebots :: find (1); $ rebot-> status = 0; $ rebot-> save ();

Use the MODEL can directly modify it? Such as:

$ rebot = new Rebots (); $ rebot-> id = 1; $ rebot-> status = 0; $ rebot-> save ();



83.4k

Yes, save() is a smart method, it checks if the record exists to creating or updating the object. This checking is performed according to the current values in the object.

If you want to avoid unexpected updates, you can use 'create' instead of 'save':

$robot = new Robots();
$robot-> id = 1;
$robot-> status = 0;
$robot-> create();