Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 7:30 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Tue, Sep 23, 2008 at 5:25 PM, Eric Butera [EMAIL PROTECTED] wrote: I generate my data access objects too. It goes against my better judgment, but performance wins out in this specific situation. getting off the point of the thread (i could care less :D), but have you seen the model taken by qcodo, propel (and likely others) where the generated layer is extended, so that subsequent re-generation does not interfere w/ customizations on the generated library? -nathan I have looked at Propel several times and I'm quite close to jumping on that bandwagon. The last time I was looking I decided against it though since it required a big base library to run properly (at least I think it was that, could be wrong). I do really like the idea of having something else take care of the DAO business for the most part. One less problem, right? My little generator just does the basic load, save (which calls update/insert based on pk), delete. From there I hand write out the actual fetch statements. I have some templates to ease the burden of doing some of the more repetitive queries, such as the ones that require pagination. I think it is very important to craft data fetching SQL statements though since that is usually the largest bottle neck of the system. After looking at that Qcodo framework for a second I've actually made another generator that creates the management side MVC pages to work off of a table too. That is an interesting idea though extending the generated classes to get around customizations. I was thinking about trying to come up with a way of doing a diff to handle this in my own generators. It is easy enough to just copy the basic methods and paste them over my current ones though. I hardly ever find myself adding new fields to tables once a job is complete so I haven't felt the motivation to do it yet. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $this-value VS $value
Hello to all my fellow members of the PHP community. As a personal rule i always use $this in front of class members, but i always knew from others programing languages and i guess I just thought it was same in PHP that without $this keyword it should work just the same, however in the code bellow it is clear that $value is not the same as $this-value. This test was done in PHP5. Anyone care to elucidate if this is correct? Tks, Ângelo class test { private $value; public function__construct() { $this-value = test; echo Not using this: . $value . br; echo Using this: . $this-value . br; } } new test(); ? output: Not using this: = Using this: = test -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 9:55 AM, uaca man [EMAIL PROTECTED] wrote: Hello to all my fellow members of the PHP community. As a personal rule i always use $this in front of class members, but i always knew from others programing languages and i guess I just thought it was same in PHP that without $this keyword it should work just the same, however in the code bellow it is clear that $value is not the same as $this-value. This test was done in PHP5. Anyone care to elucidate if this is correct? afaik, php requires instance variables to be qualified w/ $this-, no matter what. in other languages, you can omit the this (self or w/e) keyword, unless you want to settle a collision between a local variable and instance variable w/ the same identifier. unfotunately it doesnt work like that in php, and although it requires more typing, i think it makes the code more understandable at a glance. -nathan
Re: [PHP] $this-value VS $value
uaca man schreef: Hello to all my fellow members of the PHP community. As a personal rule i always use $this in front of class members, but i always knew from others programing languages and i guess I just thought it was same in PHP that without $this keyword it should work just the same, however in the code bellow it is clear that $value is not the same as $this-value. This test was done in PHP5. Anyone care to elucidate if this is correct? yes. because there is no such thing as class scope. you have global scope and you have function scope ... that's it. so when your in a method and you want to use a property of the object you need to specify exactly that (using $this-foo or MyClass::$foo for static properties). Tks, Ângelo class test { private $value; public function__construct() { $this-value = test; echo Not using this: . $value . br; echo Using this: . $this-value . br; } } new test(); ? output: Not using this: = Using this: = test -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 12:26 PM, Jochem Maas [EMAIL PROTECTED] wrote: (using $this-foo or MyClass::$foo for static properties). also self:: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $this-value VS $value
Eric Butera wrote: On Tue, Sep 23, 2008 at 12:26 PM, Jochem Maas [EMAIL PROTECTED] wrote: (using $this-foo or MyClass::$foo for static properties). also self:: Actually within a class, I think you must self:: before a static property or something shows up in the error log. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 10:41 AM, Micah Gersten [EMAIL PROTECTED] wrote: Eric Butera wrote: On Tue, Sep 23, 2008 at 12:26 PM, Jochem Maas [EMAIL PROTECTED] wrote: (using $this-foo or MyClass::$foo for static properties). also self:: Actually within a class, I think you must self:: before a static property or something shows up in the error log. yea, php will think its a local variable if not qualified w/ the self keyword and scope resolution (or w/e its called in php :D), but the name of the class and the scope resolution operator works as well. its just a hair less flexible because if the class name changes you have to update some code whereas w/ self, the code is no longer dependent upon the class name. /// psuedocode ! class A { protected static $someStatic = 5; public function doStuff() { $someStatic // php thinks this is a local var self::$someStatic // php can id this as a static var A::$someStatic // php can id this as a static var } -nathan
Re: [PHP] $this-value VS $value
Nathan Nobbe schreef: On Tue, Sep 23, 2008 at 10:41 AM, Micah Gersten [EMAIL PROTECTED] wrote: Eric Butera wrote: On Tue, Sep 23, 2008 at 12:26 PM, Jochem Maas [EMAIL PROTECTED] wrote: (using $this-foo or MyClass::$foo for static properties). also self:: Actually within a class, I think you must self:: before a static property or something shows up in the error log. yea, php will think its a local variable if not qualified w/ the self keyword and scope resolution (or w/e its called in php :D), but the name of the class and the scope resolution operator works as well. its just a hair less flexible because if the class name changes you have to update some code whereas w/ self, the code is no longer dependent upon the class name. /// psuedocode ! class A { protected static $someStatic = 5; public function doStuff() { $someStatic // php thinks this is a local var self::$someStatic // php can id this as a static var A::$someStatic // php can id this as a static var Nathan is correct, I'd like to add that 'self' is actually nothing more than a simple alias used at compile time to put the class name in ... 'self' literally equates to 'MyClass', but it saves hassle when refactoring and it's much clearer that you mean 'this class Im looking at/working in' personally whenever I see a classname referenced statically inside a method I kind of assume it must be another class :-P ... now had 'self' been late (statically) bound ... no I won't go there, we get 'static' very soon now :-P } -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 6:25 PM, Jochem Maas [EMAIL PROTECTED] wrote: Nathan Nobbe schreef: On Tue, Sep 23, 2008 at 10:41 AM, Micah Gersten [EMAIL PROTECTED] wrote: Eric Butera wrote: On Tue, Sep 23, 2008 at 12:26 PM, Jochem Maas [EMAIL PROTECTED] wrote: (using $this-foo or MyClass::$foo for static properties). also self:: Actually within a class, I think you must self:: before a static property or something shows up in the error log. yea, php will think its a local variable if not qualified w/ the self keyword and scope resolution (or w/e its called in php :D), but the name of the class and the scope resolution operator works as well. its just a hair less flexible because if the class name changes you have to update some code whereas w/ self, the code is no longer dependent upon the class name. /// psuedocode ! class A { protected static $someStatic = 5; public function doStuff() { $someStatic // php thinks this is a local var self::$someStatic // php can id this as a static var A::$someStatic // php can id this as a static var Nathan is correct, I'd like to add that 'self' is actually nothing more than a simple alias used at compile time to put the class name in ... 'self' literally equates to 'MyClass', but it saves hassle when refactoring and it's much clearer that you mean 'this class Im looking at/working in' personally whenever I see a classname referenced statically inside a method I kind of assume it must be another class :-P ... now had 'self' been late (statically) bound ... no I won't go there, we get 'static' very soon now :-P } -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Active Record sucks :P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 4:25 PM, Jochem Maas [EMAIL PROTECTED] wrote: ... now had 'self' been late (statically) bound ... no I won't go there, we get 'static' very soon now :-P and lets not forget the __*Static() magic method suite we're getting too :) -nathan
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 4:42 PM, Eric Butera [EMAIL PROTECTED] wrote: Active Record sucks :P i prefer code generation to runtime introspection, but runtime introspection+code generation, well thats a compromise i can live w/ ;) -nathan
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 7:20 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Tue, Sep 23, 2008 at 4:42 PM, Eric Butera [EMAIL PROTECTED] wrote: Active Record sucks :P i prefer code generation to runtime introspection, but runtime introspection+code generation, well thats a compromise i can live w/ ;) -nathan I generate my data access objects too. It goes against my better judgment, but performance wins out in this specific situation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $this-value VS $value
On Tue, Sep 23, 2008 at 5:25 PM, Eric Butera [EMAIL PROTECTED] wrote: I generate my data access objects too. It goes against my better judgment, but performance wins out in this specific situation. getting off the point of the thread (i could care less :D), but have you seen the model taken by qcodo, propel (and likely others) where the generated layer is extended, so that subsequent re-generation does not interfere w/ customizations on the generated library? -nathan