ODBC Driver for LinkedIn Marketing Solutions

Build 23.0.8839

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

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

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

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

$stmt = odbc_prepare($cnx, "SELECT VisibilityCode, Comment FROM Analytics WHERE EntityId = ?");

odbc_execute($stmt, array("238 1"));
while ($row = odbc_fetch_array($stmt)) {
    echo "VisibilityCode = ", $row["VisibilityCode"], "\n";
    echo "Comment = ", $row["Comment"], "\n";
}

odbc_execute($stmt, array("238 2"));
while ($row = odbc_fetch_array($stmt)) {
    echo "VisibilityCode = ", $row["VisibilityCode"], "\n";
    echo "Comment = ", $row["Comment"], "\n";
}

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