App accessing mysql db on different server

I am quite new to app development in nextcloud environment, but currently i am stuck:

I am developing an app which needs access to another mysql server (readonly access to the data maintained by a different application). How do I create a DB connection to this server?

Accessing the nextcloud server is not a problem and works fine for me. From this point the developer documentation is fine for me.

So far, in other (non-nextcloud) applications I was using PDO library, but the statement “new PDO(…)” for opening a new database connection results in an error.

Alternatively I need to retrieve a IDBConnection to this server, but where can I configure hostname, db name, db user and db password for this separate connection?

I hope I am clear with my description. Any help is appreciated. Thank you in advance!

I think you just need to include the appropriate class(es).

use PDO;

Thanks for the help! This was exactly my mistake.
So far I did PHP programming without using namespaces… so no need to use “use” so far…

2 Likes