[pmwiki-devel] More database standards

Ben Stallings ben at interdependentweb.com
Fri Dec 15 10:46:19 CST 2006


Hi, Marc.  Thank you for posting that function excerpt; it makes things 
much clearer.  I think I see now where our strategies differ.

Your function acts on three tables, which it has already decided it is 
going to call 'products', 'orderitems', and 'orders', regardless of what 
they may actually be called.  It is therefore necessary to tell the 
function which actual tables these handles refer to, and in which 
database those tables are located.  You propose doing this through a 
global array $DBTables, defined in config.php, of the format

$DBTables[handle] = array('database'=>database, 'table'=>table)

Am I right so far?

The recipes I'm working with, in contrast, are so general in purpose 
that they don't refer to their tables by handles; they use variables 
that they are passed.  A separate object is created for interacting with 
each database connection, and the connection name is passed when the 
object is created and is stored as $object->db so that it need not be 
passed in any of the function calls.  The table names are passed in the 
function calls because they tend to be different each time.

Because I'm coming from this different perspective, I didn't see the 
point of your $DBTables array.  I couldn't understand why the function 
needed to look up the names of the tables it was supposed to work with, 
because in my framework the names are part of the function call.

So now I wonder if maybe the $DBTables array, useful as it is for your 
purposes, is not general enough to need a place in the Database Standard 
but could just be part of the configuration for your recipe(s).

>> It doesn't get past the limitation (imposed 
>> by ADOdb) that both tables must be on the same database in order to use 
>> them in the same query.
> 
> And how do you propose to do that? What would be your SQL syntax?

Well, I don't propose to do that, because we decided to go with ADOdb, 
which doesn't support that.  If we were working with MySQL alone, 
without ADOdb being involved, the SQL syntax would be, for example,

SELECT moodle.users.lastlogin,pmwiki.users.lastlogin FROM moodle.users, 
pmwiki.users WHERE moodle.users.userid = pmwiki.users.userid AND 
pmwiki.users.userid = $author;

It's not really relevant now that I know what you're talking about, but 
before I knew that I was speculating about why you wanted to specify the 
database for every single individual field, and the only reason I could 
think of was that you wanted to use more than one database in a query.

Thanks for helping me understand!  --Ben S.



More information about the pmwiki-devel mailing list