[pmwiki-devel] dataquery and ADOdb errors in general
marc
gmane at auxbuss.com
Thu Jan 11 07:45:05 CST 2007
Ben Stallings said...
> Marc wrote,
>
> > ADOdb has an inbuilt error handler.
> > Would it not be simpler to manage all db errors in one place?
> > And all that for all dbs in a dozen lines in adodb-errorhandler.inc.php
> > and a single notify line.
>
> Sounds great!
It is. Being able to exploit notify is a boon.
> Why not post a modified script (with a different
> filename) to the Database Standard recipe page so we can try it out?
Done.
http://www.pmwiki.org/wiki/Cookbook/DatabaseStandard
> While you're at it, you could share the other improvements you've told
> us about.
As I said, I'm out of that one. I hope folk eventually see the benefits
of returning an object from ADOdbConnect(), but if not, then nothing is
lost. As far as I'm concerned, to use db recipes, I only have to strip
out the error handling code and tweak a few if statements. The downside
- if you can call it that - is that I can't release any db recipes
because they won't work with adodb-connect.php.
In any case, I've moved over to using the active record pattern - since
I'm committed to OO - and that has simplified things still further, and
works very well with PmWiki markup, imo. Failing once, I doubt I could
convince folk of this method.
For example to support the following (find something in db on PmWiki
page):
(:displayobject object=Member value='userName like "%ben%"' :)
Only takes a few lines
function displayObject($opt) {
global $ClassD;
$defaults = array( 'object' => '', 'value' => '');
$opt = array_merge($defaults, ParseArgs($opt));
extract($opt);
if (file_exists("$ClassD/Class.$object.php"))
require_once "$ClassD/Class.$object.php";
else
return "No class definition '$object' for object.";
# or create class defn dynamically via extend of AuxAR
$inst = new $object();
$loaded = $inst->load($value);
if (! $loaded) return "no object found";
return $inst->display();
}
Do this via a form and you have a db browser - in minutes. Note that the
display() method is specific to the class, but it inherits a default
that steps through via introspection (I ignore /^_/ vars and unpack
arrays).
--
Cheers,
Marc
More information about the pmwiki-devel
mailing list