From 843deba89571f558e4b570109eb976a592d0e199 Mon Sep 17 00:00:00 2001 From: jackbravo Date: Tue, 27 Nov 2007 00:01:12 +0000 Subject: [PATCH] Added docs for the construct() method --- manual/docs/en/working-with-objects.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/manual/docs/en/working-with-objects.txt b/manual/docs/en/working-with-objects.txt index 9cd8fc5a2..e49850f23 100644 --- a/manual/docs/en/working-with-objects.txt +++ b/manual/docs/en/working-with-objects.txt @@ -158,3 +158,20 @@ $users[0]->description; Doctrine does the proxy evaluation based on loaded field count. It does not evaluate which fields are loaded on field-by-field basis. The reason for this is simple: performance. Field lazy-loading is very rarely needed in PHP world, hence introducing some kind of variable to check which fields are loaded would introduce unnecessary overhead to basic fetching. + +++ Overriding the constructor + +Sometimes you want to do some operations at the creation time of your objects. Doctrine doesn't allow you to override the Doctrine_Record::__construct() method but provides an alternative: + + +class User extends Doctrine_Record +{ + public function construct() + { + $this->name = 'Test Name'; + $this->do_something(); + } +} + + +The only drawback is that it doesn't provide a way to pass parameters to the constructor.