ODBC Driver for Blackbaud Financial Edge NXT

Build 23.0.8839

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

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

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

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

$stmt = odbc_prepare($cnx, "SELECT AccountId, AccountNumber FROM Accounts WHERE ModifiedBy = ?");

odbc_execute($stmt, array("System 1"));
while ($row = odbc_fetch_array($stmt)) {
    echo "AccountId = ", $row["AccountId"], "\n";
    echo "AccountNumber = ", $row["AccountNumber"], "\n";
}

odbc_execute($stmt, array("System 2"));
while ($row = odbc_fetch_array($stmt)) {
    echo "AccountId = ", $row["AccountId"], "\n";
    echo "AccountNumber = ", $row["AccountNumber"], "\n";
}

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839