Code changed to support different database names and table prefix, also utf8
-
I add my two cents tip with code changed to support database names others than moodle and table prefix other than mdl_ , also add support to international charset to be used in others languages than english.
Enjoy it and excelent plugin.
—————— Search and change in the file
//CHANGE localhost, MYSQLusername, MYSQLpassword, MYSQldatabase and MYSQLtableprefix to be used in a database with an account that has read only access to your Moodle database. Your Moodle website may not be on the same server as WordPress in which case you will need to change localhost to an IP address of the server that contains your Moodle database. This may require additional setup on your Moodle server.
$dbhost = “localhost”;
$dbuser = “MYSQLusername”;
$dbpass = “MYSQLpassword”;
$dbname = “MYSQLdatabase”;
$tbl_prf = “MYSQLtableprefix”;
$con = mysql_connect($dbhost,$dbuser,$dbpass);
//If you are using an international charset be sure to use utf8 chars inside database and uncomment the next line
mysql_set_charset(“utf8”);
if (!$con) {
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db($dbname, $con);$username = $instance[‘name’];
$username = mysql_real_escape_string($username);
$query_course_list = “SELECT c.id AS courseid, c.fullname
FROM “.$tbl_prf.”role_assignments ra
JOIN “.$tbl_prf.”user u ON u.id = ra.userid
JOIN “.$tbl_prf.”role r ON r.id = ra.roleid
JOIN “.$tbl_prf.”context cxt ON cxt.id = ra.contextid
JOIN “.$tbl_prf.”course c ON c.id = cxt.instanceid
- The topic ‘Code changed to support different database names and table prefix, also utf8’ is closed to new replies.