[pmwiki-devel] More database standards

marc gmane at auxbuss.com
Thu Dec 14 06:40:18 CST 2006

Crisses said...
> On Dec 13, 2006, at 2:11 PM, marc wrote:
> > To complicate matters, where there is more than one database, you  
> > could
> > be passing around multiple connection names. In addition, how is a
> > recipe writer to cater for the situation where one table comes from  
> > one
> > db and a second from another? And perhaps a third. Or a fourth.
> >
> > Is there a proposed solution for this?
> I don't know.  I know how I've handled it for AuthUserDBase so far.   
> I've used SDVA and given a sample sql script for how to set up the  
> database, but only for the standalone version.  The very nature of  
> AuthUserDBase was to share the login settings of another database  
> already managed by another program (say vBulletin, Joomla!, Drupal,  
> Moodle.....or now, with ADOdb, maybe even LDAP?).
> I had to set default values, but allow people to change them.  I've  
> added a hook for an admin-created function to do the encryption for  
> the database, since I can't predict the encryption methods used by  
> every program out there, and the vBulletin one was double MD5 with a  
> salt.
> So, I suggest you wrap your definitions in SDVA for arrays, SDV for  
> variables, and let the admin sort it out, get something into a  
> testing phase, document what you can, and get feedback from people.

No, that's not it. Consider a recipe that needs to open a db. Which db 
does it open? Now, the recipe needs to perform a SELECT on a table. 
Which table, and what name?

It's the same issue that you have with AuthUserDb, but in a general 
rather than specific case.

Anyway, I've settled on a PmWiki-ish way to handle this that may or may 
not work for others. It can still utilise the SDV() approach - to 
maintain that mechanism.

The nub of it is a two-dimensional array that would usually live in 
(farm)config.php. Something like:

  $DBTables = array (
    'products' => array ('database' => $liveDb, 'table' => 'products')
    'members'  => array ('database' => $testDb, 'table' => 'users')

This can then be used in recipes via [1]:

  global $DBTables;

and, say:

  $db = ADOdbConnect($DBTables['products']['database']);
  $sql = "SELECT * FROM {$DBTables['products']['table']}

Hopefully, this makes the problem, and my suggested solution, a bit 


[1] Although, personally, I prefer to do 

  global $DBTables;
  extract ($DBTables['products']);

  $db = ADOdbConnect($database);
  $sql = "SELECT * FROM $table

More information about the pmwiki-devel mailing list