![]() |
php8.1、codeigniter4.1.8
hi, there. I interesting create an application for school. Use the model from SchoolController. PHP Code: class SchoolController extends BaseController OK, I got a entity. https://drive.google.com/file/d/1TCzPnIB...qE8U2/view but I can't use method this entity. PHP Code: class SchoolController extends BaseController https://drive.google.com/file/d/1bTYWUUN...p=drivesdk I look at the following URL in the forum and I want an entity that contains the entity in the relation table https://forum.codeigniter.com/thread-80298.html Maybe I think it's fact due to php8.1. Do you know the solution? How do you make a constructor for a entity? https://codeigniter4.github.io/userguide...ities.html# https://stackoverflow.com/questions/5926...e-initiali for information PHP Code: <?php PHP Code: <?php
Entity uses the $attributes property to store data. This storage is accessed either directly or through getters and setters.
Since you declared the properties corresponding to the fields, no getter/setter is called when accessing them. This means there is no access to the data. Remove the properties and it will work. PHP Code: protected ?int $id; You can also remove methods. They don't make sense unless you need to mutate/calculate the data. For type casting, you can use this Property Casting Quote:iReddsEntity uses the $attributes property to store data. This storage is accessed either directly or through getters and setters. thank you for your reply. there was unnecessary declare. I will always be saved
(02-05-2022, 05:52 PM)yoshi Wrote:Quote:iReddsEntity uses the $attributes property to store data. This storage is accessed either directly or through getters and setters. This method also worked for me, and I spent hours of hard time to figure it out. |
Welcome Guest, Not a member yet? Register Sign In |