gpt4 book ai didi

php - codeigniter 事件记录查询缺少撇号

转载 作者:行者123 更新时间:2023-11-29 14:49:23 24 4
gpt4 key购买 nike

代码点火器正在吐出:

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
)

最佳答案

我刚刚经历过这个 - 我认为问题的一部分是 simplexml 返回的一些值被视为对象。不管什么原因——你必须在插入之前将值转换为字符串。值得庆幸的是,它非常简单,只需添加(字符串)

由此而来

$cardName = $result->CardName;

到此

$cardName = (string)$result->CardName;

关于php - codeigniter 事件记录查询缺少撇号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6131979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com