Moodle
  1. Moodle
  2. MDL-4011

External Enrollment does not work for database with '-' in name

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.2
    • Fix Version/s: None
    • Component/s: Enrolments
    • Labels:
      None
    • Environment:
      Linux
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_15_STABLE
    • Rank:
      11021

      Description

      Had a problem getting external enrollments to work to an external MySql database.

      Traced the problem to the database enrollment in this file:

      enrol/database/enrol.php (enrol.php,v 1.7 2005/02/08)

      I finally determined the problem could be fixed in the workaround hack section which prefixed the table name with the database name for the course select query which looks up the course by the idnumber. The query that was formed looked like this:

      SELECT * FROM MOODLE1-5-DEV.mdl_course WHERE idnumber='8194'

      To our database (MySql version 4.1.10a-standard) this is syntax error unless the table name is enclosed with the back tick '`' character:

      SELECT * FROM `MOODLE1-5-DEV`.mdl_course WHERE idnumber='8194'

      I modifed the enrol.php code from:

      $CFG->prefix = $CFG->dbname.$CFG->prefix;

      to

      $CFG->prefix = `$CFG->dbname`.$CFG->prefix;

      And now enrollments work ok.

      I'm not sure if the back tick is valid for other databases, i've only been concerned with MySql and this fix worked for me.

        Activity

        Hide
        Martin Dougiamas added a comment -

        From Martin Langhoff (martin at catalyst.net.nz) Wednesday, 7 September 2005, 09:02 AM:

        Thanks for reporting this - backticks are in fact only supported on MySQL. Let me see what I can do

        From Martin Langhoff (martin at catalyst.net.nz) Wednesday, 7 September 2005, 02:14 PM:

        This problem is caused for a workaround that is MySQL-specific. As it stands, it completely breaks the enrolment plugin on other databases – as I had just found this morning.

        I have merged your fix with mine - now the workaround will quote the database name correctly... but the workaround only kicks in if both databases are mysql.

        Thanks a lot for the report and patch. Timely indeed

        Closing - reopen if needed.

        Show
        Martin Dougiamas added a comment - From Martin Langhoff (martin at catalyst.net.nz) Wednesday, 7 September 2005, 09:02 AM: Thanks for reporting this - backticks are in fact only supported on MySQL. Let me see what I can do From Martin Langhoff (martin at catalyst.net.nz) Wednesday, 7 September 2005, 02:14 PM: This problem is caused for a workaround that is MySQL-specific. As it stands, it completely breaks the enrolment plugin on other databases – as I had just found this morning. I have merged your fix with mine - now the workaround will quote the database name correctly... but the workaround only kicks in if both databases are mysql. Thanks a lot for the report and patch. Timely indeed Closing - reopen if needed.
        Hide
        Michael Blake added a comment -

        assign to a valid user

        Show
        Michael Blake added a comment - assign to a valid user

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: