I'd like to access a table found within another database other than the one stated in my settings.php file. The good thing is that the other database is found on the same server. Are SMF's database functions designed to access other databases, or must I use the database within that chosen in settings.php?
if the user that has rights to the SMF database has no rights to the other database it cannot read from it. this is handled on the server level not SMF.
I have 2 websites, each one has their own database.
Website 1 wants to access tables in website 2, sort of thing
Quote from: Study Force on May 10, 2019, 10:53:33 AM
I have 2 websites, each one has their own database.
Website 1 wants to access tables in website 2, sort of thing
Quote from: Illori on May 10, 2019, 10:51:38 AM
if the user that has rights to the SMF database has no rights to the other database it cannot read from it. this is handled on the server level not SMF.
^
sure - you can do almost anything you want - if you can code it.
However, no - you can not use SMF's database functions to access a different database. SMF's database functions are specifically written as a closed loop - they pre-parse the request, clean it (reject it if its malicious) and then access ONE database, by using ONE user and most of the functions perform ONE action.
this is security.
You could call the data from the external table and store it within the DB for SMF using an external script and then have SMF utilize it that way.
I generally do SELECT * FROM databasename.tablename that will work in smf database calls.
Quote from: vbgamer45 on May 10, 2019, 04:09:34 PM
I generally do SELECT * FROM databasename.tablename that will work in smf database calls.
I'll try that. Or, as mentioned, store the information I need from website B in a JSON file that can then be accessed via URL in website A.
Less overhead doing the sql directly. The mysql user has to have access to both databases.