0

I'm trying to set a null value on a Model column but it gets ignored and it doesn't update.

if($rol_colegio)
    $update_pl['rol_colegio'] = $rol_colegio; //$rol_colegio may be null

$usuario->update($update_pl);

The data does get updated successfully when I try to use non-null data, but if the variable is null this entry doesn't get updated.

What would be the cause of this?

2 Answers 2

3

$rol_colegion = null doesn't match condition if($rol_colegio).

Just remove if($rol_colegio).

Sign up to request clarification or add additional context in comments.

1 Comment

I'm banging my head on the desk at the moment. Thank you.
0

Just simply do like this.

$update_pl['rol_colegio'] = $rol_colegio; //$rol_colegio may be null

$usuario->update($update_pl);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.