ODBC Driver for Yahoo! Ads

Build 23.0.8839

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

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

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

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

$stmt = odbc_prepare($cnx, "SELECT AdGroupName, AuthType FROM [YahooAds].[SearchAds].SearchAdsAdGroups WHERE AccountId = ?");

odbc_execute($stmt, array("123436 1"));
while ($row = odbc_fetch_array($stmt)) {
    echo "AdGroupName = ", $row["AdGroupName"], "\n";
    echo "AuthType = ", $row["AuthType"], "\n";
}

odbc_execute($stmt, array("123436 2"));
while ($row = odbc_fetch_array($stmt)) {
    echo "AdGroupName = ", $row["AdGroupName"], "\n";
    echo "AuthType = ", $row["AuthType"], "\n";
}

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