Hello, i want to ask can i change the moodle configuration after i am logged in into the system, i am trying to connect to a external db and connect back to this my moodle db, but i can't connect to external db, how can i change the database configuration in moodle system.
Change Configuration of moodle config.php after i logged in.
Number of replies: 6Re: Change Configuration of moodle config.php after i logged in.
Create a new database connection using standard PHP functionality and use that for your interactions. Needless to say, the global $DB will still be connected to your Moodle database.
Re: Change Configuration of moodle config.php after i logged in.
Re: Change Configuration of moodle config.php after i logged in.
Ok, realize this is developer forum and am not a developer ... but ... there should remain at least 2 accounts that authenticate using moodle DB ... guest .. and the initial user that installed the moodle. IF external DB connections fail for some reason, only way to fix ... be able to login to the moodle - that's without any muss/fuss/re-config, etc.
2 cent non-developer advice from one who has been there ... done that ... and wished he hadn't!
'SoS', Ken
Re: Change Configuration of moodle config.php after i logged in.
Re: Change Configuration of moodle config.php after i logged in.
Hmmm ... see your servers config for external:
/admin/settings.php?section=authsettingdb
On the login form for Moodle, the left login/pass box for Moodle Admins. On the login form for Moodle, right panel ... a link to a crafted login for the external DB.
See
https://docs.moodle.org/38/en/Managing_authentication
That's IF I am understanding correctly!
'SoS', Ken
Re: Change Configuration of moodle config.php after i logged in.
Hi Ahmad,
I don't think there is a good way to change the database connection in Moodle. However, you can create additional connections that are independent of the Moodle database connection.
You can find very good examples in the core plugins "auth_db" and "enrol_database".
auth_db: in lib.php the function "db_init()"
enrol_database: auth.php the method "db_init()"
In both cases you have an additional connection that you can use to do your requests to the external database.
I hope that helps a little.
Best regards
Andreas