I just thought it would make things simple
I'm still learning that OO stuff hehe, thought static would set the scope to class instead of object for find.
That way you would have to pass the object as a parameter to the static find, so that it would get access to object data (since find is from the class, not the object).
And that didn't seem like an elegant way eighter hehe
Probably there are other ways...
I should have waited for other replies, shut up and read hehe, but i fail that from time to time...
Hans Lellelid wrote:
Andre Cerqueira wrote: >> >> $c = new Criteria(Author::NAME, "Leo"); >> $a = AuthorFinder::find($c); >> >> instantiated behavior for performing customizations: >> >> $c = new Criteria(Author::NAME, "Leo"); >> $af = new AuthorFinder(); >> $af->setLimit(5); >> $a = $af->find($c); >>
I think it should be constructor's job to set up an instance with the defaults. (no need for static in this case)
Am i missing something?
static, default behavior, probably accounts for 80% of uses:
Well, kinda, yeah. The other part of the equation is that this class is generated, which is what allows it to be static. The default values for things are built into the class as static properties or class constants or whatever.
The idea is that most of the time this class is really a static class, which needs no object instance to perform 'find' functions.
Of course, you're right, using it non-statically only is a solution, but it would be far more elegant (IMO) if that weren't necessary :)
Cheers, Hans
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php