Databases: PostgreSQL Connection Approach

Databases: PostgreSQL Connection Approach

by Dave Thorne -
Number of replies: 1
Hello,

I am a developer in the UK looking into how Moodle could help some schools in the Manchester area, and being duly impressed I have installed it on our system.

We wanted to use PostgreSQL (as we already had a server running - and we think it would handle better for the number of users we were planning on catering for) but I found a problem with the PHP code.

In the lib/setup.php file, the pg_[p]connect() functions use a form that has been deprecated in PHP now and so no longer works. The old version (as I found in the 1.0.9 download) uses a function which takes multiple parameters to connect to the database, whereas the form for the latest versions of PHP only takes one parameter, i.e. a single connection string which incorporates the above parameters. Please look at:

http://uk2.php.net/manual/en/function.pg-connect.php

for the documentation on the current form of pg_connect(). I have modified my copy of the code to fix this but I was wondering if this was widely known to be a problem. I have found a post on the forums that dates back to September last year where someone mentioned this but as far as I can see it has not been rectified.

When will this be implemented?

Dave Thorne
Average of ratings: -
In reply to Dave Thorne

Re: Databases: PostgreSQL Connection Approach

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
Moodle doesn't use pg_connect.

The function you are referring to in lib/setup.php is $db->Connect() or $db->PConnect()

These are ADOdb functions (look in moodle/lib/adodb). A look at Postgres drivers for ADOdb seems to show that they support either form of connection.

Since you've fixed something perhaps you could describe exactly what you've done and attach a patch - I'll be happy to fix it once I know what the problem is.