尝试提交以下sql代码时出现错误:
$Query = "Insert into EzyCat15.CompanyCards (`CC_StoreID`, `EC_CC_Card_ID`, `CC_Card_Type`, `CC_Type`,
`CC_Company_Name`, `CC_Company_Trading_Name`, `CC_ABN_Number`,
`CC_Tax_Code`, `CC_Shipping_Tax_Code`, `CC_Default_Currency`,
`CC_Default_PriceType`,`CC_Payment_DueType`, `CC_ MethodInvoice`, `CC_InvoiceTemplate`, `CC_PrintPackingSlip`, `CC_PackingSlip_Template`,
`CC_Card_Status`, `CC_Fax`,
`CC_URL`,
`CC_ReviewedModifiedBy`)
values
(:CC_StoreID, :EC_CC_Card_ID, :CC_Card_Type, :CC_Type,
:CC_Company_Name, :CC_Company_Trading_Name, :CC_ABN_Number,
:CC_Tax_Code, :CC_Shipping_Tax_Code, :CC_Default_Currency,
:CC_Default_PriceType, :CC_Payment_DueType,:CC_ MethodInvoice, :CC_InvoiceTemplate, :CC_PrintPackingSlip, :CC_PackingSlip_Template,
:CC_Card_Status, :CC_Fax,
:CC_URL,
:CC_ReviewedModifiedBy)";
$this->CrosscheckPDO($Query, $data);
$Query = $this -> conn -> prepare($Query);
$Query -> execute($data);
我写了一些代码来从sql中剥离参数,并将它与我的$ data变量进行比较,寻找双方丢失的数据字段。
public function CrosscheckPDO($query, $params) {
$r = explode(':', $query);
unset($r[0]);
foreach ($r as $key => $value) {
$value = str_replace(',', '', $value);
$value = trim(str_replace(')', '', $value));
$r[$key] = $value;
if (!isset($params[$value]))
$params[$value] = '!!!!!';
$t[$value] = $params[$value];
unset($params[$value]);
}
echo "Query Variables";
print_r($r);
echo "Query Pairs";
print_r($t);
echo "Param Variables";
print_r($params);
}
CrossCheckPDO的输出显示:
Query VariablesArray ( [1] => CC_StoreID [2] => EC_CC_Card_ID [3] => CC_Card_Type [4] => CC_Type [5] => CC_Company_Name [6] => CC_Company_Trading_Name [7] => CC_ABN_Number [8] => CC_Tax_Code [9] => CC_Shipping_Tax_Code [10] => CC_Default_Currency [11] => CC_Default_PriceType [12] => CC_Payment_DueType [13] => CC_ MethodInvoice [14] => CC_InvoiceTemplate [15] => CC_PrintPackingSlip [16] => CC_PackingSlip_Template [17] => CC_Card_Status [18] => CC_Fax [19] => CC_URL [20] => CC_ReviewedModifiedBy ) Query PairsArray ( [CC_StoreID] => 89 [EC_CC_Card_ID] => 54f2d1c6d6920 [CC_Card_Type] => C [CC_Type] => I [CC_Company_Name] => Mr. Carl GettingFedUp [CC_Company_Trading_Name] => Individual [CC_ABN_Number] => Not Set [CC_Tax_Code] => GST [CC_Shipping_Tax_Code] => GST [CC_Default_Currency] => AU [CC_Default_PriceType] => R [CC_Payment_DueType] => PrePay [CC_ MethodInvoice] => E [CC_InvoiceTemplate] => Default [CC_PrintPackingSlip] => N [CC_PackingSlip_Template] => Default [CC_Card_Status] => Pending [CC_Fax] => Not Set [CC_URL] => Not Set [CC_ReviewedModifiedBy] => 0 ) Param VariablesArray ( )
这似乎与Prepaired语句的参数一对一匹配,但我仍然遇到主题行错误。
谁能看到我在这里做错了什么?
卡尔。