Re[2]: [psa-devel]Database Table Names
Brought to you by:
koivi
From: Alex E. <ta...@sp...> - 2003-07-28 14:41:11
|
On Monday, July 28, 2003, 9:57:30 AM, Albert wrote: > Glad to hear you've got the system working well for you. Making the db > prefix customizable is a useful feature. > What may make sense is to make it easily customizable. In the default > shipping, it would be set to "PSA_". If the user, like you have done, wants > to have a different prefix, they can change the config, then manually update > the schema. > Post a bit of what you've done to the list and we'll see if it makes sense > to go for it. Okay, Here is a little of what I have done. This is not comprehensive of my changes, but gives the general idea. IN CONFIG.PHP I ADDED ----------------------------------------- 'TblPrefix' => 'folio_', ----------------------------------------- to the $PSA_SCR array IN class.phpSecuirtyAdm.php I ADDED ----------------------------------------- // The database table prefix stuff if(isset($PSA_SCR['TblPrefix'])){ $this->TBL_PREFIX=$PSA_SCR['TblPrefix']; }else{ $this->TBL_PREFIX='folio_'; } ----------------------------------------- to force the prefix to whatever I wanted if the user left the config blank. I am using PSA in another app, as most users probably are, so I am using that apps shortname to prefix the db. This may not totally be necessary, but it could help if someone deletes the setting from config.php accidentally. So, then in all the pages where DB calls are made, I added a line similar to this one: ----------------------------- $query='UPDATE '.$PSA_SCR['TblPrefix'].'psa_sessions SET expiry='.$expiry.', value='.$PSA_SESS_SQL->GetTextFieldValue($val). ----------------------------- OR ----------------------------- $query="SELECT pass, hash, active, lockcount, connection FROM ".$this->TBL_PREFIX."psa_users WHERE id=".$this->db->GetTextFieldValue($user); ----------------------------- within the class. It's really straightforward. Some of the issues I found were: 1. Ensuring that the $PSA_SCR was within the scope of some of the functions, especially within sessions.php. 2. Working with the _sequence tables, I ended up just letting them be something like _sequence_folio_whatever instead of making it a strict prefix. The code for that was something like ------------------------------ $result=$this->db->GetSequenceNextValue($this->TBL_PREFIX.'psa_profiles_id',$id); ------------------------------ What do you think? -- Alex http://www.spittingllamas.com "Formal Restrictions, contrary to what you might think, free you up by allowing you to concentrate on purer ideas." - Winter Sorbeck in Chip Kidd's The Cheese Monkeys |