[Xerte-dev] Re: 1.9 thinking
David Goodwin
david at palepurple.co.uk
Wed Jul 4 11:52:51 BST 2012
> <snip/>
>
> 1) Restructure / replace the sitedetails table with a more logical structure
>
I'd suggest you use the 'config' table which already has name/value pairs :
e.g.
SELECT value FROM config WHERE name = "site_name"
SELECT value FROM config WHERE name = "site_email"
SELECT value FROM config WHERE name = "ldap_server1"
This will allow you to easily add in additional fields/values later on.
Retrieval would be easiest through something like :
_get_config('some_name') => returns "fish fingers";
_set_config('key_name', 'value')
or
Config::getValue('some_name') => returns 'fish fingers'
Config::setValue('key_name', 'value')
It would be relatively easy to add in an additional method which would return a data structure like what your legacy code expects -
e.g.
_get_config_all() => …. (as below)
Config::getAllInOne() => returns array('site_name' => 'xxx', 'site_email' => 'xxxx at xxx') and so on.
Whether you want it to be OOified or just a "boring" procedural function is up to you / whoever writes it.
I'm not sure there's any need for a Config object as such (e.g. $c = new Config(); $c->setName('xx'); $c->setValue('yy'); $c->save()).
David.
Pale Purple Ltd. (Company No: 5580814)
'Business Web Application Development and Training in PHP'
http://www.palepurple.co.uk
Office: 0845 0046746 Mobile: 07792380669
Follow us on Twitter: @PalePurpleLtd
More information about the Xerte-dev
mailing list