Re: [PROPOSAL] DB_Simple

From: Date: Sat, 01 Nov 2003 13:39:29 +0000
Subject: Re: [PROPOSAL] DB_Simple
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-23174@lists.php.net to get a copy of this message
Hi, Alexey, On Nov 1, 2003, at 3:32 AM, Alexey Borzov wrote:
Overall impression: not impressed.
OK. :-)
Two problems with the package name: 1) It is *absolutely* impossible to understand what this package does by looking at its name 2) This was raised when I proposed HTTP_SimpleClient package: "Simple" in the name implies either "dumb" or the existance of "Complex" package.
Fair enough -- DB_DataObject is taken, but perhaps something along those lines.
See the two attached files for the DB_Simple class and an example extension class.
the "example extension class" will not work, its php4-style constructor calls its php5-style constructor but passes nothing to it.
Oops! My bad, I just threw it together as a quick example. However, the principle is the same: the extension only needs to set the SQL and column mappings.
- DB_SIMPLE_INTNOSIGN
     unsigned long integer, typcially BIGINT UNSIGNED
MySQLism?
No, each supported database uses its own internal datatypes for numbers and strings; I call the MySQL example is "typical" only because it's typical for me, although MS-SQL is looming in my future.
================= Column Definition ----------------- Finally, an example of a calculated column: $this->column['area'] = array(
    'type' => DB_SIMPLE_FLOAT,
    'calc' => "length * width",
    'index' => DB_SIMPLE_INDEX
);
Client-side views? How sweet.
Well, it is "simple" after all. ;-)
Quoting the comment buried *deep* inside createTable(): // add the field definition ... // mysql only for now, include others later If the package supports only MySQL, then it has to have MySQL in its name.
I should have removed the comment; it is not MySQL only, although I have not tested it on others. Please note the class property $_declare; it has field declaration keywords for a number of different databases.
$this->sql['getList'] = array(
    DB_SIMPLE_SELECT => array('id', 'username', 'email'),
    DB_SIMPLE_WHERE => "division = 'Information Technology'",
    DB_SIMPLE_ORDER => "username"
);
Is this any easier than to directly write SELECT id, username, email FROM tablename WHERE division = 'Information Technology' ORDERB BY username The manually written query has less chars in it, BTW.
One might ask the same thing about DB_DataObjects, and the answer is "yes and no." Maybe I am not a good SQL guy; sometimes I want a baseline list, and sometimes I want to filter that baseline list. Having a basic query as a property, and then adding a different filter to it in different methods, has been useful to me in the past.
=========================================== Automated INSERT and UPDATE With Validation ------------------------------------------- ...
Will it also check for column constraints, foreign keys and the like? Besides, this info is *not* read from DB, but provided by the user -> inconsistencies.
No, at least not yet -- do all the supported databases use all those features? I have tried to find the common denominators between the supported databases and abstract them, but it's possible I missed some.
And my all-time favourite error message, from delete() method: return $this->raiseError("The WHERE clause in your DELETE " .
    "statement has no operator (=, <, <=, >, >=, LIKE) in it; " .
    "this might delete all records.  Request denied.");
Will the package also try to wipe my nose?
Only if the $kleenex property is set to boolean true. ;-) Seriously, I've stupidly sent "DELETE FROM table" commands before, and that only little bit of code would haved save my but at least once.
BTW, what about DELETE FROM tablename WHERE 1 = 1?
Then you're asking for it, and so it's OK.
============ Known Issues ------------ DB_Simple should throw error codes, not just error messages. DB_Simple has only been tested with MySQL.
Once again: if this was told from the very beginning, then I wouldn't bother reading further.
My apologies; sorry to have wasted your time. However, it is supposed to work with other databases; I only have access to a MySQL installation at this time. -- pmj

« previous php.pear.dev (#23174) next »