how to convert from MySQL specific to generic code?

how to convert from MySQL specific to generic code?

by Jelle Boomstra -
Number of replies: 3
Hello Developers,

The questionnaire module in development is based on phpesp. it has been partly incorporated into moodle, but it still relies on mysql calls for the database acces. I believe it is more usefull to do something instead of asking somebody else to do it, so I want to convert that mysql code to (moodle-)generic code. (and my itch here is that i run moodle on PostgreSQL and would like to use the questionaire module)
Instead of reinventing the wheel and figuring everything out myself, may I ask some other developers where and how to start?

In particular, how do I get the db connection etc set up? I assume I have to include some file, but is that it, no other hoops to jump through?

I already found the functions in lib datalib.php, I guess I have to find the equivalents for the mysql functions there. Any pointers in that regard?

Mike, since you are the developer of this module, would you mind if I try this?
Average of ratings: -
In reply to Jelle Boomstra

Re: how to convert from MySQL specific to generic code?

by Keith Heinrich -

Jella

I am guessing here but I suspect that the database connectivity is abstracted which means the database functions will work with either My SQL or PostgreSQL. Only the driver should differ.

Of course I could be mistaken...

In reply to Keith Heinrich

Re: how to convert from MySQL specific to generic code?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
There are a couple of database abstraction libraries that might be useful for this. They are peardb and adoDB. Moodle uses adodb so that is probably a good choice.  Having written php with native calls to mysql I believe adodb is easier to learn and use (plus  you get the portability benefits).

You can find out more from http://adodb.sourceforge.net
In reply to Marcus Green

Re: how to convert from MySQL specific to generic code?

by Jelle Boomstra -
well, some digging in the config file revealed that I only have to include that one. I just converted the fisrt function in espauth-moodle.inc and it appears to work/does not bug out on the syntax.
I am more or less stabbing in the dark here, so no error is good enough for now (from the instruction manual: how to create bugs" smile )