Moodle with Pear DB

Moodle with Pear DB

by Howard Miller -
Number of replies: 8
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If anybody is interested, I have written a library class that lets Moodle run with the Pear 'DB' database abstraction class rather than adodb.

It's simply a matter of having the class in the lib directory and loading it in place of the adodb class in lib/setup.php. That's it, there are no other changes to any other Moodle files. I have it set up on my test machine using a $CFG variable and a check for either library in setup.php.

The main restrictions at the moment is that it has only been tested with mysql and it is not compatible (weirdly) with caching, so that has to be turned off in the admin=>filters screen (some very strange things happen with it on). I'm working on that one.

I can submit it to CVS or just post it here if there is interest. I would consider it experimental at the moment smile
Average of ratings: -
In reply to Howard Miller

Re: Moodle with Pear DB

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In fact here it is attached.

Instructions:
* turn off cacheing in admin=>filters (even if you don't use filters)
* put the file peardb_adodb.php in your lib directory
* In lib/setup.php at or about line 85 comment out the include_once for adodb and replace it with a similar line that points to peardb_adodb.php

That's all you need. You are now using Pear's 'DB' database abstraction library instead of adodb. Please note that this has 'only' been tested with mysql on Linux using 1.5dev. If you loose all your data don't blame me, but I'm reasonably confident that it works.
In reply to Howard Miller

Re: Moodle with Pear DB

by Ziba Scott -
That hidden inner part of me that irrationally prefers Pear to Adodb applauds you.
In reply to Ziba Scott

Re: Moodle with Pear DB

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
big grin

I have the same irrational thoughts. Of course, in the last ten minutes I have found a couple of bugs - new version coming soon I hope!
In reply to Howard Miller

Re: Moodle with Pear DB

by Martín Langhoff -
Howard -- this is *really* interesting. I'm full of questions...

What are the (rational) drivers? Does PEAR DB have better DB abstraction? Is it demonstrably faster (have you got benchmarks)? Is it more compatible with weird databases?

In reply to Martín Langhoff

Re: Moodle with Pear DB

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Martin,

I'm not sure it's anything too exciting. It just uses the native PHP drivers. Although PEAR has it's ups and downs I have generally been impressed with the work of this project. They seem committed to producing high quality products.

I have always liked it better because the interface seems much more intuitive than adodb and it has (relatively) decent documentation.

To complicate matters DB is, strictly speaking, deprecated and replaced by MDB (there is MDB2 at alpha stage as well). However not many standard installs seem to have it. MDB, allegedly, was/is heavily profiled for best performance.

The supported databases should be the usual suspects (from my install):
fbsql, ifx, mssql, oci8, pgsql, storage, dbase, ibase, msql, mysql, odbc, sqlite, sybase
(of course, assumes your system has the relevant drivers compiled in)

I haven't done an A/B comparison with adodb (yet). It will be interesting to try.
In reply to Howard Miller

Re: Moodle with Pear DB

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Here's another version (attached) with the last lot of bugs fixed. In particular, cacheing now works fine - you don't have to switch it off. Unless anybody objects, I might submit this into CVS as it might come in useful and only requires a trivial change to setup.php.

One thing I forgot to mention, was that you need to make sure that DB.php is on your path, so installations do this - others don't, regardless of the PEAR files being installed. On my SuSE 9.1 system I had to edit php.ini thus

include_path = .:/usr/share/php

(/usr/share/php being where the PEAR stuff lives)
In reply to Howard Miller

Re: Moodle with Pear DB

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Do they have good solutions yet for table creation/maintenance?   Last I looked (while back) they hadn't yet.