if you go to a base class of the model you won't find any get or set method.
It is because those methods is said are created "on the air".
What does it mean exacltly, I suspect it just means they are created in the moment they are needed.
Am i right? What are the advantages of the way rescpect of generate the methods inside the base class?
Regards
开发者_如何学PythonJavi
Doctrine uses PHP's magic methods to implement, amongst other things, the get*()
and set*()
methods, so it will check to make sure the column exists, and if so, get or set the value accordingly.
In addition, Doctrine will also check to see if you have implemented your own individual get/set methods, eg getSurname()
and use this in preference to just setting the column value directly.
richsage is correct that the getXXX
and setXXX
methods are done via PHP's "magic" __call
method, but it is not Doctrine doing the magic. It is sfDoctrineRecord::__call
that transforms an invocation like $record->getName()
to $record->get('name')
.
精彩评论