ODBC Driver for Microsoft Dynamics 365

Build 22.0.8462

Discovering Schemas

The following sections show how to obtain schema information.

List Tables and Views

You can use the odbc_tables function to discover what tables and views are available through the driver. This returns results through a resource like a query would.

$stmt = odbc_tables($cnx);
while ($row = odbc_fetch_array($stmt)) {
    echo "Catalog: ", $row["TABLE_CAT"], "\n";
    echo "Schema: ", $row["TABLE_SCHEM"], "\n";
    echo "Table: ", $row["TABLE_NAME"], "\n";
    echo "Type: ", $row["TABLE_TYPE"], "\n";
}

You can use the odbc_columns method to discover what columns are available on a table or view.

$stmt = odbc_columns($cnx);
while ($row = odbc_fetch_array($stmt)) {
    if ($row["TABLE_NAME"] == "GoalHeadings") {
        echo "Name: ", $row["COLUMN_NAME"], "\n";
        echo "Type: ", $row["DATA_TYPE"], "\n";
        echo "Length: ", $row["COLUMN_SIZE"], "\n";
        echo "Precision: ", $row["DECIMAL_DIGITS"], "\n";
        echo "Nullable: ", $row["IS_NULLABLE"], "\n";
    }
}

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462