[nycphp-talk] How to dynamically generate class methods based on dbfield values
David Sklar
sklar at sklar.com
Tue Oct 14 17:40:31 EDT 2003
How about something like
class Foo {
$fields = array('bar' => 1, 'baz' => 1, 'quux' => 1);
function get($field) {
if ($this->fields[$field]) { return $this->$field; }
}
}
David
On Tuesday, October 14, 2003 5:33 PM, wrote:
> dbfield values
>
>
> I am having to be tasked with a rather painful task of updating an
> existing class by adding a dynamic amount of database field values;
> for each database field value there has to be a generated array
> inside the class plus a function "get method" to return it.
>
> I do not want to have to constantly type out:
>
> function getStuff() {
> return $this->stuff;
> }
>
> for every occurrence of stuff I find that is generated by the database
> SELECT call on the fields of as many as 20 different tables!! This is
> enormous and I would love a more dynamic, functional method to
> generate.. methods.
>
> Can someone give me an idea of how this can be done?
>
> Thanx
> Phil
>
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .
>
>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
More information about the talk
mailing list