Re: [Postfixadmin-devel] refactoring [ZF stuff]
Brought to you by:
christian_boltz,
gingerdog
From: Christian B. <pos...@cb...> - 2008-08-14 21:36:11
|
Hello, Am Dienstag, 29. Juli 2008 schrieb David Goodwin: > 21:36 < lenix> ok, i've made a first step and managed to dump the > model of my current db-structure into some PHP/ZendFramework code > 21:36 < lenix> see http://lenix.de/pfaModel.phps and > http://lenix.de/pfaModel.sql Looks good, but I'm still not sure if we a) need a class for each table b) need a "big" abstraction layer for doing some SELECT, INSERT, UPDATE and DELETE operations The other option would be a small database class with a syntax like $db->begin # begin transaction - or simply ignore call if not supported $db->insert($table, $values_array) $db->update($table, $primarykey_field, $primarykey_value, $values_array) $array = $db->select($table, $cond, $limit, $orderby) and some helper functions like $db->cond($field, $operation, $value) # example: $db->cond("domain", "=", "example.com") $db->and($cond1, $cond2, $cond3, ...) # used to build WHERE clauses # example: $db->and($db->cond(...), $db->cond(...) ) $db->or($cond1, ...) # same with OR The helper functions might look superfluous, but they make the statements independent from the SQL language. The advantage I see with this solution: It would be really lightweight and only contain what we really need. When thinking further: what would be easier for someone who wants to add LDAP support? (I'm not a LDAP user/admin/fan, but it looks like some people would like to use it. So we should at least try to make it easy for them.) > 21:38 < lenix> $_columns is for reference-purposes only, i don't know > whether such a variable does exist in ZF OK, this would have been my first complaint otherwise. We (will) have the table structure in $struct already, duplicating it in the database class is pointless. We have the database structure in upgrade.php also, but I'm afraid we won't be able to avoid this - unless someone extracts the database scheme comparison from Typo3 ;-) > 21:41 < lenix> GingerDog: i intended to add some validation-routines > and an usage-example first.. I'll have validation code in my module class already, not sure if you need additional validation in the database class. Having some usage examples (for insert, update, delete and select) would be nice. Regards, Christian Boltz -- "Guten Tag, ich möchte gerne einen Tisch reservieren." "Gerne, auf welchen Namen denn?" "31337 /-/ /\ X0R!" [Jens Benecke in suse-linux zum Thema Realnames] |