Re: [Fwd: Issue with DB_DataObject]
| From: | Justin Patrin | Date: | Fri, 07 Jan 2005 17:30:46 +0000 |
| Subject: | Re: [Fwd: Issue with DB_DataObject] | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16788@lists.php.net to get a copy of this message | ||
On Fri, 7 Jan 2005 19:00:44 +1100 (EST), daniel@electroteque.org
<daniel@electroteque.org> wrote:
>
> >>
> >
> > Yeah, the ini/global thing has always been strange. However, you can
> > eschew the ini files and just override the table(), links(), and
> > keys() functions to just return the correct arrays. This way you have
> > no config files to parse and everything is stored in the DO. You could
> > also put them in member vars and have those functions return them if
> > you want.
> >
> >> regards,
> >> Lukas
>
>
> Anyone got an example of the full methods for a single DO on a table, so i
> can go and modify thegenerator to give the options to add this in ? Right now there is not much
> examples to do so, yehi'd prefer not to have all the field and foreign key relationships
> in an
> ini file.
>
Note: the generator may put these auto-gen functions in the auto-gen
section, but it should not create new ones if the functions exist
outside of the auto-gen section (I override these functions for
various interesting things ;-))
class DataObject_Table extends DB_DataObject {
//normal auto-gen stuff
function table() {
return array('id' => DB_DATAOBJECT_INT | DB_DATAOBJECT_NOT_NULL,
'name' => DB_DATAOBJECT_STR,
'otherTable_id' => DB_DATAOBJECT_INT,
//etc
);
}
function links() {
return array('otherTable_id' => 'otherTable:id',
//etc);
}
function keys() {
if ($args = func_get_args()) {
return call_user_func_array(array('DB_DataObject', 'keys'), $args);
} else {
return array('id',
//etc);
}
}
}
--
Justin Patrin