Advertisement:

Author Topic: Possible to access different database within same server?  (Read 352 times)

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,586
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Possible to access different database within same server?
« on: May 10, 2019, 10:44:27 AM »
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?

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 50,570
Re: Possible to access different database within same server?
« Reply #1 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.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,586
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Possible to access different database within same server?
« Reply #2 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

Online SychO

  • Customizer
  • Sophist Member
  • *
  • Posts: 1,187
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Possible to access different database within same server?
« Reply #3 on: May 10, 2019, 11:10:30 AM »
I have 2 websites, each one has their own database.

Website 1 wants to access tables in website 2, sort of thing

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.

^

Imazighen

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,062
  • Gender: Male
    • Kindred-999 on GitHub
Re: Possible to access different database within same server?
« Reply #4 on: May 10, 2019, 11:56:23 AM »
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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Looking

  • SMF Hero
  • ******
  • Posts: 2,318
  • SMF Customization
    • jeanborde on Facebook
    • SMF Custom Themes & Custom Coding
Re: Possible to access different database within same server?
« Reply #5 on: May 10, 2019, 03:12:16 PM »
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.

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,176
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Possible to access different database within same server?
« Reply #6 on: May 10, 2019, 04:09:34 PM »
I generally do SELECT * FROM databasename.tablename  that will work in smf database calls.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,586
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Possible to access different database within same server?
« Reply #7 on: May 10, 2019, 05:02:01 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.

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,176
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Possible to access different database within same server?
« Reply #8 on: May 10, 2019, 05:18:46 PM »
Less overhead doing the sql directly. The mysql user has to have access to both databases.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro