<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV><BR class="khtml-block-placeholder"></DIV><DIV>On Oct 14, 2006, at 4:33 PM, Ben Stallings wrote:</DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Crisses wrote:</DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">You need an identifier though. A nickname. Because what if (gasp) you have multiple mysql databases? ADODB is database agnostic, so use an agnostic method of addressing the database definitions -- then they can be on any server, and multiple of the same type -- or from the same program -- can be used:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">$DQConnections['moodleA'] = array ();</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR style=""></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">They're not much different from one another, just keep in mind that you do need to give each database setting a unique name.</DIV></BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR style=""></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Each database already has a name; that's one of the parameters that has to be passed in order to make the connection. Giving another name to the connection would be redundant, since there can be only one connection to a given database at a time, and it would also be transient, since $WikiLibDirs is an array of unnamed objects.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR style=""></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Besides, if admins add objects to $WikiLibDirs themselves, rather than relying on the script to do it, they will have the intriguing option of overwriting the default PageStore ($WikiLibDirs[0]) and thereby making their wikis database-driven... not that there's anything wrong with flat files at all, but if hypothetically you wanted a database-driven PmWiki, all you'd have to do is overwrite the default PageStore.</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I must be walking in in the middle of something I don't "get". I'm looking at this from the overall perspective of CookbookAuthorsUnite -- you're looking at it for your own recipe.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The subject line makes this sound rather generic, like the values/arrays being discussed are settings that many cookbook authors would be sharing. So I thought about it from my own point of view, of course, which is that of the AuthUserDBase perspective, where technically one could grab usernames/authentication methods from multiple databases -- even of the same type (mysql, etc.)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>You were talking about using a variety of databases, but in the definitions I see things like type ("mysql") and "database" and "server" but not a specific distinct name of each, and I thought "if I wanted to authenticate people against multiple databases, I would have to name them". It's the user-friendly thing to do.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Ok, maybe that's not at all where you're going. If you're not doing anything regarding user authentication, then maybe I'm wrong about this.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>One thing I notice while working on recipes is the (occasional) repetition of the same database connection data. And maybe while we're discussing a method of similar database abstraction (adodb) we should discuss a way to not have unnecessary repetition of database login info, while still allowing admins to access different databases if they want to. For example, maybe your pagestore is on the same server, maybe even the same database, as the authentication that would be accessed by AuthUserDBase. Why would the admin repeat the info?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Having a unique human-readable label for each database (and database connection!) would be helpful here. PHP has this wonderful way of allowing you to call function and name names by way of variables.</DIV><DIV>$Databases['moodle'] = array(connection info...); // $Databases['moodle']['type'] is "mysql"</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>AuthUserDBase could have</DIV><DIV>$AUDuse = 'moodle';</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>then (if $$AUDuse isn't defined...):</DIV><DIV>$$AUDuse = new NewADOConnection($Databases[$AUDuse]['type']);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Now there's a class instance for that connection named $moodle -- but we never need to know that. Individual recipes can test whether another recipe already defined the connection with ADOdb, creating less class instances that are redundant. $Databases['??'] is optionally human-readable by the admin, and can be whatever value the admin wants in whatever language, or can be a code, numbers, etc. For the programmer it's just a matter of typing an extra $ and thinking a bit more expansively.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>This also helps protect the namespace. How many people are going to define </DIV><DIV>$db = new NewADOConnection('mysql');</DIV><DIV>straight out of the documentation -- causing potential namespace clashes between recipes....</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Are there other concerns?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>You said "each database already has a name" but I don't find $db to be particularly descriptive or safe. That's not a "name" but a storage container used on the programming end, not the administrator end, of a recipe. "there can only be one connection to a given database at a time" -- this is not true. I can easily do $db1 and $db2 as two connections, perhaps each looking at a different table of the same database...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If I'm authenticating someone from tableA and you're storing pages in tableB of the same database, we could share the same connection/data -- or we can have multiple connections and duplicated authentication data. Databases are all about multiple connections.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>When writing vbulletin.php I used adodb but the same authentication as the AuthUserDBase -- so I copied the variables -- what a waste. I thought there should be a better way to share the same info. Many hosting services only give you one database to connect to. Why are admins required to duplicate their data because the cookbook authors can't agree on one method to share this data (and maybe even connection!) between their recipes?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Whatever we do, we have to allow multiple databases and servers while making it easier on the administrator(s).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>----</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Another reason I'm writing is to verify whether you're working on database-based authentication. I'm slated to work, alone or with Ben Wilson, on improving AuthUserDBase and incorporating ADOdb, etc. If you're working on it, then I shouldn't. We don't need more confusion, Ben & I discussed eliminating confusion by merging the AuthUserDBase and XesAuthUserDBase recipes. So I wanted to check whether or not this is something that is part of your recipe. I doubt it, but it's better that I ask.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR><DIV> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="1" style="font: 9.0px Monaco">Crisses</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="1" style="font: 9.0px Monaco">--<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="1" style="font: 9.0px Monaco">I am Jack's supposedly fictitious alter ego.</FONT></P> </DIV><BR><DIV><BLOCKQUOTE type="cite"></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>