Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    So I've got a MySQL database with the user info, such as username, password, email, account type, etc.
    Now I want to have a second database, with settings in it. Such as background image, and color scheme.
    How would, once they're logged in, I use the information for the second database?

    Thank you

  2.  

  3. #2
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    It your talking about having a seperate DB to hold user preferences, when you create the record for the user in the user table create a row in the preference table with some default values, and the user_id from the user table...

    Then set set some session variables that hold that info ( like username, etc. ), the next time they login, once you've authenticated them, call that preferences table and set their session preferences...

  4. #3
    Junior Member SimplyWebsites's Avatar
    Join Date
    Jul 2012
    Location
    Leicester
    Posts
    27
    Member #
    32160
    Seperate database or seperate tables?

    I wouldn't reccomend having 2 databases but i think you mean having 2 tables then you would store the user_id for each settings record and then look it up once they are logged in.

  5. #4
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    No I mean seperate databases. Even though you're right I could use seperate tables too...
    What I mean was, say I hgave it said up as follows:
    1. User logs in with his email address and password. This is in a database called USERS
    2. From a second database, certain preferences like the background color/image of the website, are pulled.

  6. #5
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    If you use 2 seperate DB's you have to open 2 specific connections. Depending on how well the DB servers are setup, this could actually slow everything down.

    Since you're going to need some kind of record identifier in both DB's to compare user connections, you're talking about a lot of overhead for something that can be done easily, just as securely and a lot more efficiently using 1 DB and multiple tables.

  7. #6
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    If the 2nd database is on the same server, you don't *need* a 2nd connection.

    You can just use the db name as a prefix to your table name in your query, e.g.:

    (assuming you're connected to the database containing the "users" table)
    Code:
    SELECT users.username, prefs.preference, prefs.value
    FROM users
    INNER JOIN preferences_database.user_preferences AS prefs
        ON prefs.user_id = users.id;
    However, as others have, I strongly suggest against this architecture. It's not optimal by any means.

  8. #7
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    Hmm... I'd only need one connection if I make a db user that has full permissions to both dbs. Correct?

  9. #8
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    See my response above: correct.

  10. #9
    Senior Member Zboost's Avatar
    Join Date
    Apr 2011
    Location
    Houston
    Posts
    246
    Member #
    27459
    Liked
    20 times
    Why two separate database might I ask, and yes this is a bit old, I am just curious.

  11. #10
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    Quote Originally Posted by Zboost, post: 239430
    Why two separate database might I ask, and yes this is a bit old, I am just curious.
    Well, because it would make maintenance and security better.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:01 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com