Database connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcel

    Database connection

    <?php

    I have a question about 2 connection strings to a ms sql database.

    # TEST DATABASE

    $connecttest = MSSQL_CONNECT(" TEST", "sa", "123456") or exit("Unable to
    connect to MS SQL Server at 10.0.10.58");

    $select = mssql_select_db ("database1",$c onnecttest) or exit("Unable to
    select database TEST");


    # PRODUCTION DATABASE

    $connectprod = MSSQL_CONNECT(" PROD", "sa", "654321") or exit("Unable to
    connect to database at 10.0.10.59");

    $select = mssql_select_db ("database2",$c onnectprod) or exit("Unable to
    select database PROD");


    $SQL = "SELECT * FROM table1";

    $RESULT = mssql_query($SQ L);


    // What data will i find here? Is it data from the TEST or from PROD and
    will it be data from database1 or from database 2?

    ?>


  • Steve

    #2
    Re: Database connection

    [color=blue]
    > // What data will i find here? Is it data from the TEST or from PROD and
    > will it be data from database1 or from database 2?[/color]

    It will be from the most recently opened resource, but if you are ever
    in any doubt then explicitly state which connection to use...

    $RESULT = mssql_query($SQ L,$connectprod) ;

    ---
    Steve

    Comment

    • Meiao

      #3
      Re: Database connection

      If you use PEAR's DB
      you can use 2 connections at a time (i think)

      Comment

      • Marcel

        #4
        Re: Database connection


        "Steve" <googlespam@nas tysoft.com> schreef in bericht
        news:1129625680 .819633.223710@ g44g2000cwa.goo glegroups.com.. .[color=blue]
        >[color=green]
        >> // What data will i find here? Is it data from the TEST or from PROD and
        >> will it be data from database1 or from database 2?[/color]
        >
        > It will be from the most recently opened resource, but if you are ever
        > in any doubt then explicitly state which connection to use...
        >
        > $RESULT = mssql_query($SQ L,$connectprod) ;
        >
        > ---
        > Steve
        >[/color]

        Ok thanks a lot!


        Comment

        Working...