Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Even when a record is queried?

I see many events (beforeUpdate, beforeSave etc) but I want to convert a value to real boolean right after its "find" or "findFirst"-ed. How can I do it?


Class Model {

    public $bool;

    function afterFetch(){
        if php >= 5.5.
            $this->bool = boolval($this->bool);
            $this->bool = (bool) $this->bool

If i understand you right, a user had same issue few days ago. Check this topic and the accepted answer:

Tell us if that helped you.

@kisb2 Izo's solution is cleaner then mine;

@izopi4a thanks for sharing, i kinda missed that from the docs, really usefull!


yea, right. Actually I was browsing at but "afterFetch" is not in that "Events and Events Manager" table


UPDATE: but it wont effect the resultset if I convert it to array (->toArray();)


show me you db connection, the whole piece of the pie :D . Without the password ofcourse