ODBC Driver for Zoho Books

Build 22.0.8479

パラメータ化されたステートメント

次のコード例は、パラメータをバインドしてパラメータ化されたステートメントを作成する方法を示します。

リユーザブル ステートメント

odbc_prepare 関数は、プリペアドステートメントを作成します。これは、odbc_execute への複数の呼び出しで再利用できます。ステートメントオブジェクトはパラメータ化されていないクエリのように結果をフェッチするために使用できます。

$stmt = odbc_prepare($cnx, "SELECT InvoiceId, InvoiceNumber FROM INVOICES WHERE CustomerName = ?");

odbc_execute($stmt, array("NewTech Industries 1"));
while ($row = odbc_fetch_array($stmt)) {
    echo "InvoiceId = ", $row["InvoiceId"], "\n";
    echo "InvoiceNumber = ", $row["InvoiceNumber"], "\n";
}

odbc_execute($stmt, array("NewTech Industries 2"));
while ($row = odbc_fetch_array($stmt)) {
    echo "InvoiceId = ", $row["InvoiceId"], "\n";
    echo "InvoiceNumber = ", $row["InvoiceNumber"], "\n";
}

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