PHP PDO ODBC connection

后端 未结 2 1617
别那么骄傲
别那么骄傲 2020-12-17 04:45

we are trying to create a connection with our SQL database trough ODBC in PHP.

This is our current script:

$cnx = new PDO(\"odbc:Driver={EFR};Serve         


        
相关标签:
2条回答
  • 2020-12-17 05:04

    try adding DSN on System instead of user

    0 讨论(0)
  • 2020-12-17 05:12

    if you already have the ODBC defined and have a stored password, you can simply connect with

    $conn = new PDO("odbc:DSN_NAME") 
    

    where DSN_NAME is the actual name of your ODBC datasource, be it MySQL, SQL Server or DB2.

    You can test your connection with the following:

    try{
        $conn = new PDO ("odbc:DSN_NAME");
    
        die(json_encode(array('outcome' => true)));
    }
    catch(PDOException $ex){
         die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
    }
    
    0 讨论(0)
提交回复
热议问题