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.

afterFetch + createBuilder

Hi, i have a situation that need a createBuilder and in resultset i need that should execute method afterFetch of model class, this method will convert the format of date. how i can resolve this problem with createBuilder, what is better way?


Have you tried this? Without testing, my guess would be that afterFetch() gets called on the models after the query is executed. Remember the query isn't necessarily executed when the builder is created, but when it's data is first access.

Another solution might be to declare the date as a private class variable. Then, override __get() and __set() to convert the format at the time the variable is retrieved and set.

It should be called until you select full objects.