codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.39k stars 1.9k forks source link

Set the raw data: Any other reason besides setting a password? #6663

Closed neznaika0 closed 2 years ago

neznaika0 commented 2 years ago
    Any other reason besides setting a password?

I extended the Entity class by adding private properties. abandoned the magic of setters/getters - created get set Now setAttributes cannot call set* So fill() is the better solution. Regarding the password hash - this operation is done in the beforeInsert Model or by setting the hash yourself

Originally posted by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/issues/2011#issuecomment-1274160221

neznaika0 commented 2 years ago

Maybe return solution? And ohter drivers

        if (is_subclass_of($className, Entity::class)) {
            return empty($data = $this->fetchAssoc()) ? false : (new $className())->fill($data)->syncOriginal();
        }

If you completely remove the check on the Entity (and the private class), then fetch_object () does not call setters, it will immediately assign values to private properties. Therefore, the situation needs to be corrected.

If I do fill() then everything works fine - private properties are set and $attributes are filled in my setters

kenjis commented 2 years ago

@neznaika0 We use GitHub issues to track BUGS and to track approved DEVELOPMENT work packages. We use our forum to provide SUPPORT and to discuss FEATURE REQUESTS.

What is it?

neznaika0 commented 2 years ago

It's probably more of a mistake. I posted on the forum