[dokuwiki] SQL API

  • From: Guillaume Turri <guillaume.turri@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 26 Sep 2011 22:45:39 +0200

Hi,

I'm writting a plugin which needs a database. I'd like it to be easy to use
(ie : to install) for the user, and portable (ie : to work with mysql, but
with other kinds of database as well). I've looked how it's usually done,
but I'm not sure I figure out the best way to deal with it.

In particular:
- The statistics plugin [1] uses the mysql API of php, and conf files to let
the wiki admin set the database information (server, database, user, ...).
Therefore, it works, but only with a mysql database, and if my plugin does
the same, the admin will have to enter his database information twice.
- I looked at the way the mysql authentication [2] works, but it seems I
can't use it for my own purpose, since 1) a server admin would have to tweak
some core files, and 2) I'm not sure I would be able to retrieve this
database information easily and reliably.
- The plugin repo [3] is interesting because it uses the pdo API and may
therefore be compatible with many kind of databases. but it has its own conf
files. In theory, I could use its helper component to get a pdo object, but
it would be odd to make such a plugin a requirement for mine.

To put it in a nutshell, I see two solutions that could fit my need:
1 - A helper plugin which could (deal with the login stuff, and ) return a
pdo object . The user would have to install 2 plugins instead of just mine,
but at least, he wouldn't have to set his connections' settings once for
every plugin which requires it (and other plugin developpers would be able
to focus only on their code, and wouldn't have to deal with this part)
It seems to me that such a plugin doesn't exist. If you confirm that I'm
correct about that, I'd be glad to take care of it.

Or

2 - Even better: a core API which would deal with this.
I know that Dokuwiki doesn't make heavy use of databases (and that's one of
the main reason it's my prefered wiki engine). But still, it seems [4] that
it could simplify (for developers and users) and centralise interesting
things.
(It could appear as optional fields in dokuwiki's admin, and a warning could
be thrown to the admin if he activates a feature which requires it, without
providing this information.)

If you think it's a good idea, I'd be thrilled to write the first version of
this (basic) api.


So, to conclude:
1 - Is there already a solution I'm not aware of, that would fit my needs?
2 - Otherwise, would added such an "pdo provider" to the core be a good
idea?
3 - Otherwise, I'll just go ahead with my idea of helper plugin.

Thank you for reading me,

Regards,
Guillaume

[1] : http://www.dokuwiki.org/plugin:statistics
[2] : http://www.dokuwiki.org/auth:mysql
[3] : https://github.com/splitbrain/dokuwiki-plugin-pluginrepo
[4] : http://www.dokuwiki.org/?do=search&id=sql

Other related posts: