Re: Re: Design Dilemma - Database Data Abstraction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# malterisio777@xxxxxxxxx / 2007-04-11 16:34:27 -0300:
> 2007/4/11, Roman Neuhauser <neuhauser@xxxxxxxxxx>:
> >
> ># malterisio777@xxxxxxxxx / 2007-04-09 19:45:41 -0300:
> >> Thanks but that's not what I'm looking for. As I said before, my problem
> >> isn't to find an implementation of an ORM, but that the concept I'm
> >working
> >> on will use a very restricted API (array operations), and I'm having
> >trouble
> >> to keep it coherent.
> >
> >Yeah, it's a bad idea, and doesn't work.
> 
> 
> If it is my idea that you think is bad and wouldn't work, I kindly ask if
> you could explain your thoughs throughly.

You have explained my thoughts quite thoroughly in the thread opener.

: I could index by the order as they are presented by the DB:
: 
: $DB['users'][0] is the first user from the query "SELECT * FROM users"
: $DB['users'][1] is the second user from the query "SELECT * FROM users"
: etc..

That's a stillborn as soon as you care about what data the 0, 1, etc
represents, for example when updating.

Or, how is it supposed to support WHERE other than on the primary key?
What if select * from atable produces more data than there's memory for?

Operator overloading is syntactic sugar, coating over method calls,
except there are additional restrictions for array keys over function
parameters (in PHP).  You still don't have the basics straight
(identifying the rows), so why bother with operator overloading.

> Besides, what's with those funky ['s and ]'s? What are they for?
> >I didn't bother to RTFM.
> 
> The operator [] is known as the array access operator, is used to refer to
> an item in an array through its index, which is contained inside the square
> brackets. It is possible to overload this operator, and the basic related
> actions (isset, unset, foreach), in PHP5.

I know, I was suggesting that no matter how idiot-proof you build it,
a loving couple somewhere will have produced a bigger idiot.

What's easy for an idiot to use is often a weak tool if you need to get
a bit more serious, cf the problems with composite keys you described.
Sure, Lego duplo is so idiot proof that a year old can bang two pieces
each against the other cheerfully.  You won't build a helicopter with
it, however.

You have trouble identifying behavior that would go naturally with the
ArrayAccess interface.  That suggests that such natural behavior might
not exist, and a method-based interface would do your users better
service.  After all, fetchByPrimaryKey($id) says much more than [$key].

Etc etc..

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux