How i am able to save just empty string to mysql varchar field, that is not allowed to be null? i can't change database fields, and i don't want to write hardcode. I can't skip it, because many actions in my project requires this field in a model. E.g.:
$model->field = ''; // empty string is a value.
$model->save(); // error
$model->field = new \Phalcon\Db\RawValue('""');
$model->save();
see here
@nikolasha Thank you very much for you link to previous same post.
About this solution - it is really funny. Whos sick brain did came up with this idea? I remembered question from stackoverflow "How it is better to calculate sum of two numbers?" and the most popular (and it was marked as correct) answer was "Use query plugins, [some plugins list, where you need to create object to each number and operator]. Only noobies and idiots calculate sum without objects". Ok. Lets create objects for each empty string value. Nice solution.
I will try some ways to re-implement validation, as phalcon said in previous post. Thank you.
But - from my point of view - this logic is _VERY_ strange. A comment for @phalcon - i will leave it here, because previous topic (linked to current) is closed. If you get empty data in models and if you save it - it is ok. You need to implement (or specify) validators, to prohibit it. Currently logic is non-usable, and very hard to understand.
P.S. Perhaps my last message is not polite. Please, take it easy, it is painful to watch how your favourite framework implement more and more strange solutions.
Keeping the discussion in #440
Most helpful comment
see here