Hi,
How would I connect to an external database using the Moodle API? Or is it a question of using the standard PHP functions?
Thanks,
Pedro Remedios
I think you should be able to create a new instance of the appropriate moodle_database class from /lib/dml (pass true to the $external parameter of the constructor), call the connect() method with the external database's credentials, then use it like you would $DB.
Hi Pedro
I think you want to other database like oracle so, you need to follow this link.
https://docs.moodle.org/30/en/Installing_Oracle_for_PHP
thanks
Actually it is an external MySQL database.
Olá Pedro,
Como ví que é de portugal, vou respoder em portugues o/
Estou trabalhando em um relatório que precisa de dados de uma base de dados externa daí usei ADONewConnection
+ require_once($CFG->libdir.'/adodb/adodb.inc.php'); | ||
+ $authdb = ADONewConnection('postgres'); | ||
+ $authdb->debug = true; | ||
+ ob_start(); | ||
+ $authdb->Connect('localhost', 'postgres', 'postgres', 'teste', true); | ||
+ $authdb->SetFetchMode(ADODB_FETCH_ASSOC); |
que é o mesmo método para a autenticação com banco de dados externo
Já está quase ficando bom o/