Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    20
    Thanks
    5
    Thanked 0 Times in 0 Posts

    What is the best way to connect to database?

    Hi

    I am new to the more complex coding (php, and MySql). My experience is in HTML and CSS. So please assume i need every bit of help you can offer...

    I have a question or two, before i commit to a large amount of time making code, that may turn out to be redundant before i even get anywhere...

    So please may everyone help?

    I need to know the best way for me to connect to a database. I'm on MySql 5.1.

    So i will describe my site example here:

    Its a bought in template. Its designed to run one database. But my host allows more databases in need be.

    The MySql connect code is a seperate php file. It uses class and public methods. This code links to another code (or the other code links to this), from another separate file, that somehow uses the prepending table prefix of 'something_'. So in other words the prepend is the first word in all the tables. And all alias tables have this prefix in place, but are somehow called through the two scripts.

    So i thought without getting it all too complicated and adding another table to the original database, i could just make a new database, and new code to connect to that at the same time the other is connected.

    Is there any problems i would need to overcome with connecting to two databases in the same session?

    Basically i need the code i write to act and know what row the data is meant to written to, or deleted from, etc. So each database would have the same number of rows, and then be updated at the appropriate row.

    Please can someone tell me... Is this method of coding called 'bridging'?

    Or does someone have a sample to post here?

    Please post samples, i need all the help i can get.

    Also, the original script uses [CODE]$retrieve[/ICODE], so do i need to assign a new variable to the second php script running a second database?

    Or is it easier to just write to the original database, but activated through the different code?

    And would there be any conflicting issues with the 'delete' rows if it was two databases? etc

    Any ideas and input is valuable, any help is appreciated.

    thanks
    sc

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,102
    Thanks
    23
    Thanked 594 Times in 593 Posts
    Quote Originally Posted by new_to_this View Post
    So i thought without getting it all too complicated and adding another table to the original database, i could just make a new database, and new code to connect to that at the same time the other is connected.
    The reality is using tables is far less complicated than what your proposing.
    Once a DB is opened it's easy to share data between tables, use multiple tables to form a coherent output or display. The list goes on and on. Stick with the one DB and multiple tables.

  • Users who have thanked sunfighter for this post:

    new_to_this (06-15-2011)

  • #3
    New Coder
    Join Date
    May 2011
    Posts
    20
    Thanks
    5
    Thanked 0 Times in 0 Posts
    thanks for the info


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •