代码点火器正在吐出:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TEST, `cardNumber` = 411111........11, `cardExpiry` = 1212, `authCode` = 110200,' at line 1
UPDATE `pxpayRequest` SET `status` = 'approved', `cardName` = Visa, `cardHolder` = VISA TEST, `cardNumber` = 411111........11, `cardExpiry` = 1212, `authCode` = 110200, `dpsTxnRef` = 0000000800b51dde, `dpsMessage` = APPROVED WHERE `id` = 1
而且,很明显,这是由于缺少'
为什么代码点火器没有将它们正确放入?
这是我的代码:
$id = $result->MerchantReference;
$cardName = $result->CardName;
$cardHolder = $result->CardHolderName;
$cardNumber = $result->CardNumber;
$cardExpiry = $result->DateExpiry;
$authCode = $result->AuthCode;
$dpsRef = $result->DpsTxnRef;
$dpsMessage = $result->ResponseText;
$this->db->set('status', 'approved')
->set('cardName', $cardName)
->set('cardHolder', $cardHolder)
->set('cardNumber', $cardNumber)
->set('cardExpiry', $cardExpiry)
->set('authCode', $authCode)
->set('dpsTxnRef', $dpsRef)
->set('dpsMessage', $dpsMessage)
->where('id', $id)
->update('pxpayRequest');
您可以通过查看上面的查询来查看相关值。
以下是$ result的print_r
SimpleXMLElement Object
(
[@attributes] => Array
(
[valid] => 1
)
[Success] => 1
[TxnType] => Purchase
[CurrencyInput] => NZD
[MerchantReference] => 1
[TxnData1] => SimpleXMLElement Object
(
)
[TxnData2] => SimpleXMLElement Object
(
)
[TxnData3] => SimpleXMLElement Object
(
)
[AuthCode] => 121132
[CardName] => Visa
[CardHolderName] => VISA CARD
[CardNumber] => 411111........11
[DateExpiry] => 1212
[ClientInfo] => 125.236.220.238
[TxnId] => 4ddd9aa1dd14c
[EmailAddress] => SimpleXMLElement Object
(
)
[DpsTxnRef] => 0000000800b5d3c9
[BillingId] => SimpleXMLElement Object
(
)
[DpsBillingId] => SimpleXMLElement Object
(
)
[AmountSettlement] => 8.00
[CurrencySettlement] => NZD
[DateSettlement] => 20110526
[TxnMac] => BD43E619
[ResponseText] => APPROVED
[CardNumber2] => SimpleXMLElement Object
(
)
[IssuerCountryId] => 0
)
答案 0 :(得分:1)
我刚刚完成了这个 - 我认为部分问题是simplexml返回的一些值被认为是对象。无论什么原因 - 你必须在插入之前将值转换为字符串。谢天谢地,它非常简单,只需添加(字符串)
所以从这个
$cardName = $result->CardName;
到这个
$cardName = (string)$result->CardName;
答案 1 :(得分:0)
尝试将第三个参数设置为TRUE。
$this->db->set('cardHolder', $cardHolder, TRUE);
答案 2 :(得分:0)
很奇怪:在任何最近应该正常工作的CodeIgniter上。我唯一能想到的就是db库没有正确识别你的数据库,或者那些变量在某种程度上没有被识别为字符串(因此没有发生转义)。 echo is_string($cardName);
说什么?
答案 3 :(得分:0)
我刚刚为此阅读了一个简单的解决方案......
我更改了var $ _escape_char的值(system / database / drivers / mysql / mysql_driver.php,第36行..
是
var $_escape_char = '`';
已更改为
var $_escape_char = ' ';
现在它可以工作......但如果我遇到任何安全问题,我很害怕..
谢谢