New HTML or Maintain DB class needed?
| From: | Stefan Fountain | Date: | Thu, 16 Jan 2003 17:22:03 +0000 |
| Subject: | New HTML or Maintain DB class needed? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-3325@lists.php.net to get a copy of this message | ||
For those of you willing to have a look at this I am wondering how and if
creating this new class is useful so please give some feedback as to the
architecture and use of such a class. Any feedback is welcome let me know if
there are known classes that already address the issues my 'new' class will
try to solve.
Thanks for your help/feedback,
Stefan Fountain
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I've been looking at creating a new class with the main purpose of being the
core section of a CMS that edits tables. I'm wondering if it is wise to
extend an existing class or make a new one. There are a lot of DB classes
already in the PEAR and one more might cause some confusion (if even it gets
added to PEAR) I would like to discuss the possibility to add
functionalities to existing PEAR classes or if necessary indeed create a new
one. Maybe there already is a DB class (or another class) that holds the
functions I want but could not find it in the PEAR browser. In a sense my
class is a HTML interface to edit DB tables.
An example of how such a class could look like :
Description:
Class that will get defined fields from a db table and return them in an
HTML list with the possibilities to edit or delete. The list will show an
add function as well. Edit will return a form with the specified record and
validate upon submit (maybe using PEAR::Quick_Form?) Add will do the same
but with blank fields. It would work similar to a script that uses a $cmd
variable to switch between commands (list, edit, add, delete). The class
would return HTML to the script that calls it, optionally this could be
extended in the future to deliver XML feeds of database results or whatever.
Class attributes:
Db connection parameters
array->(db_host, db_name, db_user, db_passw)
Table parameters
array->(table_name, array(table_fields, table_field_types), key_field)
HTML Templates
array->(list_template, edit/add template, delete_template)
(Also 'private' attributes like item_from_db_array etc.)
Class methods:
Constructor($cmd) // switches between wanted command
List_items() // calls db and lists items in local array
Add_new_item() // does as the name implies
Edit_specific_item() // does as the name implies
Delete_specific_item() // does as the name implies
Obviously there will have to be get and set methods as well as a good way of
setting up the interaction between different methods (for example edit being
the same as add but with default values returned from db)
That's the idea.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>