Insert in database return false without error |
(03-23-2020, 09:42 AM)MGatner Wrote: Could you drop the catch block and figure out exactly where the FALSE is coming from? If it is indeed from the model try checking $accountModel->errors() for anything helpful. You might also review your log settings while you're in there. https://codeigniter4.github.io/userguide...gging.html Log is setted right. I removed try-catch and same result and $accountModel->errors() is null. After some research, I found that in `$accountModel->insert(...)`call `classToArray`. That `classToArray` check `if(method_exists($data, 'toRawArray'))`, which will call that method to get my object as an raw array. Super class of `Account` is `Entity`(why? I don't know, I just did copy-paste). `Entity` has `toRawArray`, to `toRawArray` return an empty raw array(no attributes). The way is to override `toRawArray` in `Account`, but I have no reason to keep `extends Entity`. I removed `extends Entity`, but that still didn't solved the problem. Attributes of `Account` are private, and the `classToArray` collect only public and protected attributes, so I made attributes protected and now everything works fine. |
Messages In This Thread |
Insert in database return false without error - by raul1ro - 03-23-2020, 03:40 AM
RE: Insert in database return false without error - by MGatner - 03-23-2020, 09:42 AM
RE: Insert in database return false without error - by raul1ro - 03-23-2020, 12:23 PM
|