我有一個關於使用PDOPDO火鳥和參數
在火鳥2.5參數處理在PHP5中使用的問題,我有以下查詢的工作,但你可以看到,我需要命名每個參數(完全一樣)。
$sql = 'INSERT INTO orderregels
(order_ref, product_ref, variant_ref, magazijn_ref, aantal, code, omschrijving, maat, picklocatie, ean, ehprijs, korting, brutoprijs, regelbedrag, vvp, merk_ref, eenheid_ref, eenheid,
status_ref, btwtarief_ref, btwtarief, gewicht, hscode, atype)
VALUES (
:ORDER_REF,
(select product_ref from productvariant where id=:VARIANT_REF),
:VARIANT_REF2,
:MAGAZIJN_REF,
:AANTAL,
(select code from productvarianten where id=(select variant_ref from productvariant where id=:VARIANT_REF3)),
((SELECT omschrijving FROM producten WHERE id=(SELECT product_ref FROM productvariant WHERE id=:VARIANT_REF4))||\' \'||
(SELECT omschrijving FROM productvariant WHERE id=:VARIANT_REF5)),
(SELECT maat FROM productvariant WHERE id=:VARIANT_REF6),
(select magazijnlocatie from productvariant where id=:VARIANT_REF7),
(select ean from productvariant where id=:VARIANT_REF8),
(select ehprijs from productvariant where id=:VARIANT_REF9),
:KORTING,
((select ehprijs from productvariant where id=:VARIANT_REF10)*(1-(cast(:KORTING2 as numeric(18,3))/100))),
(:AANTAL2 *
((select ehprijs from productvariant where id=:VARIANT_REF11)*(1-(cast(:KORTING3 as numeric(18,3))/100)))),
(select vvp from productvariant where id=:VARIANT_REF12),
(select merk_ref from producten where id=(select product_ref from productvariant where id=:VARIANT_REF13)),
(select eenheid_ref from producten where id=(select product_ref from productvariant where id=:VARIANT_REF14)),
(select omschrijving from eenheden where id=(select eenheid_ref from producten where id=(select product_ref from productvariant where id=:VARIANT_REF15))),
1,
(select btwtarief_ref FROM orders WHERE id=:ORDER_REF2),
(SELECT percentage FROM btwtarieven where id=(select btwtarief_ref FROM orders WHERE id=:ORDER_REF3)),
(select gewicht from productvariant where id=:VARIANT_REF16),
(select hscode from producten where id=(select product_ref from productvariant where id=:VARIANT_REF17)),
1)';
$params = Array(
':ORDER_REF' => $order_ref,
':VARIANT_REF' => $variant_ref,
':VARIANT_REF2' => $variant_ref,
':MAGAZIJN_REF' => 1,
':AANTAL'=> $aantal,
':VARIANT_REF3' => $variant_ref,
':VARIANT_REF4' => $variant_ref,
':VARIANT_REF5' => $variant_ref,
':VARIANT_REF6' => $variant_ref,
':VARIANT_REF7' => $variant_ref,
':VARIANT_REF8' => $variant_ref,
':VARIANT_REF9' => $variant_ref,
':KORTING'=> $korting,
':VARIANT_REF10' => $variant_ref,
':KORTING2'=> $korting,
':AANTAL2' => $aantal,
':VARIANT_REF11' => $variant_ref,
':KORTING3'=> $korting,
':VARIANT_REF12' => $variant_ref,
':VARIANT_REF13' => $variant_ref,
':VARIANT_REF14' => $variant_ref,
':VARIANT_REF15' => $variant_ref,
':ORDER_REF2' => $order_ref,
':ORDER_REF3' => $order_ref,
':VARIANT_REF16' => $variant_ref,
':VARIANT_REF17' => $variant_ref
);
的簡化版本(未命名唯一每個參數)運行在像在Delphi使用數據庫工作臺或當查詢編輯器細。
它給了我下面的錯誤:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: -804 Dynamic SQL Error SQL error code = -804 Incorrect values within SQLDA structure '
這是真的,每次我用一個參數(即使它具有相同的名稱),我唯一他們的名字和地點他們按照他們在聲明中使用的確切順序?它需要命名參數遠的所有優點...
感謝任何信息,
克里斯蒂安
Firebird沒有命名參數,因此客戶端組件有時會模擬它。顯然,PDO不能處理具有相同名稱的多個參數。 –