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

(This post was last modified: 12-30-2021, 04:00 PM by iRedds.)

If everything works with the array, then it will work with the entity.
PHP Code:
class Model extends \CodeIgniter\Model
{
    protected 
$table 'table';
    protected 
$allowedFields = ['customer_deleted''customer_deleted_at'];
}
class 
Entity extends \CodeIgniter\Entity\Entity {}


$e = new Entity();
$e->customer_deleted null;
$e->customer_deleted_at date('Y-m-d H:i:s');

(new 
Model)->update(1$e);
// UPDATE `table` SET `customer_deleted` = NULL, `customer_deleted_at` = '2021-12-29 16:59:19' WHERE `table`.`id` IN (1) 
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