V
V
Vlad Osadchyi2018-11-19 20:52:27
MySQL
Vlad Osadchyi, 2018-11-19 20:52:27

How to write NULL to database?

There is a property (field) that has a value, for example, "bla bla bla", under certain conditions, NULL should be written to the database, DEFAULT NULL is set for this field in the database.
when I do , then emptiness or an empty string is written to the database (2 - in the picture), but definitely not NULL :D, but I need exactly NULL (1 - in the picture) UPD1: this is Yii 2, the ActiveRecord model $model->id_no = null;
5bf2f80913f1e452862533.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-11-19
@VladOsadchyi

Good evening.
You can try to solve with validation
['id_no', 'default', 'value' => null]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question