Re: DBM Compatibility layer
| From: | Brent Cook | Date: | Mon, 29 Apr 2002 04:16:14 +0000 |
| Subject: | Re: DBM Compatibility layer | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-5866@lists.php.net to get a copy of this message | ||
On Mon, 29 Apr 2002, Alan Knowles wrote:
> this is what looks like a different approach - it gets away from the
> build/execute and produces a more abstract methodoly.
>
>
> http://www.akbkhome.com/Projects/db_oo+-+an+object+based+Sql+builder+and+wrapper+for+peardb/db_oo.class.html
I had some trouble resolving www.akbkhome.com. Will try again later, and
hopefully if I see the code, the examples will make a little more sense to
me ;)
> On a base level some examples of usage
>
> /------------------------------
> mulitiple fetch.
> SELECT *,DATE('YYYY-mm-dd',creation_date) as created FROM Group WHERE
> firstname='abc' and age > 12 limit 12;
>
> $group = new Group;
> $group->firstname = "abc";
This sets a member variable called "firstname" in the group object to
"abc", right? How does the Group object know that it has this variable set
now? Perhaps when I see the code, all will be clear..
> $group->find()
What does this do?
> $group->limit(12);
> $group->condition_append('age > 12');
> $group->select_add("DATE('YYYY-mm-dd',creation_date) as created");
> while ($group->fetch()) {
> echo $group->id;
> }
This still seems to fit the build/execute scheme, which I don't see
anything wrong with, BTW. It seems to instead call execute fetch.
> There are quite a few more feature that need more documentation working
> on, but it the design of it is to help enforce putting all data
> manipulation / stored selects etc into the extended class, rather than
> the scripts - so that you would probably end up making
I like that idea.
> Group::list_pear_developers(); // which which would store the builder
> for that select in the class - hence helping enforce code reuse, rather
> than splattering this around the application....
If Group is extended, is it still called Group, e.g.
class Group extends Group {
maybe I misunderstood.
> I also started looking at DBM compatiblity - but other than simple
> insert/updates - the complex selects where a bit much for it...
I have finally written a proof-of-concept table object with select, sort
and project operators that is implemented on a DBM database. It is located
here: http://ozma.union.utexas.edu/~busterb/DBMTable.tar.gz
I hope you appreciate the simplicity of the select() function. The idea
came to me one day in the shower, after bumping my head ;)
- Brent
> regards
> alan
>