[SOLVED] CI4 Entity using datamap to Model-Save |
Hi, I have some question to the usage of Entity.
For example, I have a entity class `ActivityEntity` as below: PHP Code: class ActivityEntity extends Entity Since the project obeys the Camel-case, I re-map the column name of the database into Camel-case using `datamap` just like how the documentation describes. And my `ActivityModel` looks like: PHP Code: use App\Entities\ActivityEntity; Encounter problem while building new data using the method below: PHP Code: $newActivity = new ActivityEntity(); I was expecting the upper codes will insert a new activity data into the database, however it went wrong. The reason is that when the `save` method processing `ActivityEntity` I passed into, it didn't follow the `datamap` setting to turn `userKey` into `user_key`, hence the database is unable to write normally. I tried to call the `toArray` method within the Entity and found out the setting of `datamap` really does work, my `userKey` turns into `user_key`, but the auto-transformation I expected did not happen in the Model's `insert` and `save`, which stopped me to deal with `Entity` and create `Activity` through Camel-case. I'm not sure whether its an error or not, or I misunderstood how to use Entity. |
Messages In This Thread |
[SOLVED] CI4 Entity using datamap to Model-Save - by monkenWu - 07-14-2021, 10:32 PM
RE: CI4 Entity using datamap to Model-Save - by InsiteFX - 07-15-2021, 12:30 AM
RE: CI4 Entity using datamap to Model-Save - by monkenWu - 07-15-2021, 03:04 AM
RE: CI4 Entity using datamap to Model-Save - by MGatner - 07-15-2021, 04:35 AM
RE: CI4 Entity using datamap to Model-Save - by monkenWu - 07-15-2021, 12:49 PM
RE: CI4 Entity using datamap to Model-Save - by InsiteFX - 07-16-2021, 03:15 AM
RE: [SOLVED] CI4 Entity using datamap to Model-Save - by kenjis - 12-24-2021, 09:19 PM
|