ODBC Driver for SQL Server

Build 21.0.7958

Querying Data

After Connecting, you can execute a SQL statement and retrieve the results.

SELECT Procedure

You can execute queries using odbc_exec. This will return a resource that you can use to read results.

$stmt = odbc_exec($cnx, "SELECT Id, ProductName FROM \"SampleDB\".\"Sample\".Products WHERE ProductName = 'Konbu'");

Iterating over the Results

You can use odbc_fetch_array to fetch the next row as an array.

while ($row = odbc_fetch_array($stmt)) {
    echo "Id = ", $row["Id"], "\n";
    echo "ProductName = ", $row["ProductName"], "\n";
}

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7958