Welcome Guest, Not a member yet? Register   Sign In
Model Update ignores null
#6

(This post was last modified: 12-30-2021, 05:10 AM by AngelRodriguez.)

(12-30-2021, 04:34 AM)iRedds Wrote: You can pass an array instead of an entity.
PHP Code:
$data = [
    'field' => 'key',
];
$model->update($id$data);
// or
$data = [
    'id'      => $id,
    'field' => 'key',
];
$model->save($data); 


Yes, I know that array works, but Entity Object doesn't work, is a bug?

(12-30-2021, 04:18 AM)kenjis Wrote: Do you want the soft-deleted record to be restored?

How about this?
1. Get the record with withDeleted()
2. Change the properties
3. Save it

I do that, but if I change properties passing data as object to save(), doesn't work. It only works with array. Is a bug?
Reply


Messages In This Thread
Model Update ignores null - by AngelRodriguez - 12-29-2021, 08:10 AM
RE: Model Update ignores null - by kenjis - 12-29-2021, 05:43 PM
RE: Model Update ignores null - by AngelRodriguez - 12-30-2021, 03:18 AM
RE: Model Update ignores null - by kenjis - 12-30-2021, 04:18 AM
RE: Model Update ignores null - by iRedds - 12-30-2021, 04:34 AM
RE: Model Update ignores null - by AngelRodriguez - 12-30-2021, 05:08 AM
RE: Model Update ignores null - by iRedds - 12-30-2021, 03:49 PM
RE: Model Update ignores null - by kenjis - 12-31-2021, 03:55 AM
RE: Model Update ignores null - by AngelRodriguez - 01-03-2022, 06:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB