1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can you use pages display data from another database?

Discussion in 'XenForo Development Discussions' started by mrb1972, Jan 26, 2011.

  1. mrb1972

    mrb1972 Active Member

    Ok, im not a dev so this is probably a stupid question but would it be possible to create a page that shows data from another mysql database on the same webserver?
  2. Luke F

    Luke F Well-Known Member

    If you know what you are doing, yes, easily.
  3. mrb1972

    mrb1972 Active Member

    Thanks for the reply, thats interesting to know.. as you can probably guess I dont know what im doing ;)
  4. Kier

    Kier XenForo Developer Staff Member

    All that would be required would be a PHP callback that connects to the other database, fetches the data and exposes it to the page as part of the view parameters.
  5. mrb1972

    mrb1972 Active Member

    Ok sounds interesting.. is it possible to also create an add-on in the admincp with allows you to add/edit/save the data to/from the other database?

    The reason im asking is that the second database will have quite a lot of data (thousands of records) so im trying to decided if its better to
    1. Have it in a seperate database with its own backend and pull it into a xenforo page
    2. or Try to integrate it into xenforo as an add-on and put the data in the same database xenforo uses,

    Which solution would be best performance wise? Im just trying to work out the best direction to take
  6. Brogan

    Brogan XenForo Moderator Staff Member

    I have a similar set up (database-wise) on my existing forum.
    There are the usual forum tables and about 40 extra tables with several hundred thousand records.

    I didn't notice any problems, performance related or otherwise, from doing it this way.
  7. mrb1972

    mrb1972 Active Member

    ok, do you manage this extra data via an admincp add-on?
  8. Brogan

    Brogan XenForo Moderator Staff Member

    Apologies, I should have clarified that my current set up uses phpBB (we're switching soon) so that part isn't applicable.

    We will be reintegrating this second database at some point so I will decide then which way to go.
    I'm leaning towards the same database again so we can make use of members, permissions, etc.
  9. mrb1972

    mrb1972 Active Member

    ahh ok.. the data I have to display is open to all so dosent need any links to permissions etc. ..
  10. Andy.N

    Andy.N Well-Known Member

    I would be interested in hearing some sample code from people in the know. Looks like it could be useful for website that are more data/stats oriented.
  11. mrb1972

    mrb1972 Active Member

    yes, lets hope so.. it is actually stats data im looking to use..
  12. ragtek

    ragtek Guest

    Hm, you would just need to create a second db connection.^^

    I have only a vBulletin sample code atm http://www.vbulletin.com/forum/show...-2-widgets?s=175bc370086a420968c0a0c0a6448ae0
    And i can't port this to xenforo, until i finish my cms

    what do you all mean with an add-on?
    Something like this: http://ragtek.org/blog/forumsoftwar...bulletin/news-rund-um-mein-oscommerce-widget/ (just check the form^^)
    A add-on doesn't make sense, because everybody needs different stuff, and a add-on which is creating a acp page with a form for the database connection is IMHO useless without the queries, etc...
  13. mrb1972

    mrb1972 Active Member

    It would be custom add-on just for my needs - I would be able to manage the data from the second database, edit/add/delete records from the admincp etc, then be able to display that data in a xenforo page based on certain custom queries

Share This Page