[pmwiki-devel] pmwiki-devel Digest, Vol 3, Issue 12
Ben at InterdependentWeb.com
Sat Dec 9 11:49:20 CST 2006
> Using my preferred object oriented approach to db access in PmWiki
> recipes, I've started to build a toolkit of markup for db manipulation
> and reporting. In the hope that it might be of interest to the
> community, I thought I'd give a brief example, to see whether it might
> be of more general use and be something we could work on expanding
> As per the PmWiki Database Standard, usage is underpinned by ADOdb
> (ADOdb lite, in my case) and $Databases[$dbName]. However, rather than
> the function ADOdbConnect() returning true or a text message (as with
> adodb-connect.php), my version either returns the db object or false.
> I've argued before why I prefer his method.
That's great... I hope you'll contribute your modifications to the
DatabaseStandard recipe page and associated Talk page, rather than just
posting pieces of code to the list out of context. If you have a
working script, please share the whole script so we can try it out. Thanks!
I have no problem with the ADOdbConnect() function returning a database
object instead of TRUE, but I do have a problem with it returning FALSE
instead of an error message. As you say, $DB['db_name']->ErrorMsg()
will not work if there is no such object because the connection failed,
so it is crucial that the function returns an error message to the
recipe that calls it, so that we can know *why* the connection failed.
FALSE is just not enough information.
I also would like to maintain the use of the $DB global so that recipes
can do tricks like
foreach ($DB as $name->$db) $tables[$name] = $db->MetaTables();
without having to assign the $DB variable themselves. Particularly if
the recipe contains several functions (like DataQuery is shaping up to),
it will need to pass the database connection between functions anyway
... so I feel strongly that it should be a global assigned by the
connection script so we can share it between recipes.
Aside from that, by all means, make your changes and post your version
of the script as version 0.2! And comments can go in the Talk page. ;-)
Your DatabaseHack looks like a useful tool, too... why not post it as a
Thanks for your work on this project!! --Ben S.
More information about the pmwiki-devel