I'm looking for 开发者_如何学编程a way to let Doctrine generate getters and setters for me, because otherwise it will call the Doctrine_Record "get" method which costs a lot of time.
so is there a chance to do that?
It seems that this functionality was removed some time ago: http://trac.doctrine-project.org/ticket/1188
However, someone prepared a patch for you: http://coolsoft.altervista.org/en/blog/2009/03/how-make-symfonydoctrine-generate-accessors
That's not how Doctrine works and as kuba wrote the feature was removed from Doctrine (there were reasons to do so). The current stable version relies heavily on magic functions. Accessing the fields via the magic getters and setter like Doctrine is doing it does not cost that much time. There are other parts of doctrine that are much more time consuming. So if you have performance issues with doctrine you should "attack" that "problem" by using array results for your query (i.e. fetchArray instead of execute). That's saving a lot of time and memory. If you need objects you can hydrate the array data to an object as needed.
The creation of getter and setter is some kind of micro-optimization that will may cause you a lot of trouble. If I were you I would keep going the standard way of Doctrine.
精彩评论