<?php

 try {
     $user = 'dbusername';
     $pass ='dbuserpassword';
     
     //the odbc connection must match the definition in /etc/odbc.ini
     //In this example we defined mssql so the odbd connections is odbc:mssql
     
     $mssqlpdo = new PDO("odbc:mssql", $user,$pass);
     $mssqlpdo->setAttribute(PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

 } catch (PDOException $e) {
     $message = sprintf(
         'Unable to connect to the database: %s: The error id is [%s]',
         $e->getMessage(),
         uniqid('ERROR-')
     );
     echo $e->getMessage();

 }

try {

    $sql = "SELECT TOP 10 * FROM People"; //generic query to test.

    $query = $mssqlpdo->query($sql);

    print_r($query->fetchAll());

} catch (PDOException $e) {
    $message = sprintf(
        'Query failed: %s: The error id is [%s]',
        $e->getMessage(),
        uniqid('ERROR-')
    );
    echo $e->getMessage();

}


?>