PHP编写的语句不';t与intval()一起工作

PHP编写的语句不';t与intval()一起工作,php,int,prepared-statement,converter,Php,Int,Prepared Statement,Converter,请看我的代码: $insertStmt=$conn->prepare(“插入订单(OrderID、OrderTrackingNumber、OrderTotal、CustomerID)值(?,,,?)”; $insertStmt->bind_参数($ssdi)、$orderID、strval(“尚未发货”)、$orderTotal、$userID); 如果($insertStmt->execute()){ $insertStmt=$conn->prepare(“插入到ordersproducts(

请看我的代码:

$insertStmt=$conn->prepare(“插入订单(OrderID、OrderTrackingNumber、OrderTotal、CustomerID)值(?,,,?)”;
$insertStmt->bind_参数($ssdi)、$orderID、strval(“尚未发货”)、$orderTotal、$userID);
如果($insertStmt->execute()){
$insertStmt=$conn->prepare(“插入到ordersproducts(OrderID,ProductID,ProductSeld)值(?,?)”;
$updateStmt=$conn->prepare(“更新产品集ProductQuantity=?其中ProductID=?”;
foreach($orderedProducts作为$orderedProduct){
$productQuantity=intval($orderedProduct->productQuantity)-intval($orderedProduct->ProductAddedQuantity);
$insertStmt->bind_参数(“sii”、$orderID、intval($orderedProduct->ProductID)、intval($orderedProduct->productAddeQuantity));
$updateStmt->bind_param(“ii”,intval($productQuantity),settype($orderedProduct->ProductID,“integer”);
如果($insertStmt->execute()&&$updateStmt->execute()){
如果($updateStmt->受影响的_行==1){
$isSuccefull=TRUE;
}否则{
$isSuccefull=假;
打破
}
}否则{
$isSuccefull=假;
echo$insertStmt->error.“|”。$updateStmt->error;
打破
}
}
}
$updateStmt->bind_param
行,如果我通过
intval($orderedProduct->ProductID)
$orderedProduct->ProductID
转换为int,那么
updateStmt
将不起作用
($updateStmt->受影响的行=0)
。但是,我使用
settype($orderedProduct->ProductID,“integer”)然后它将像冠军一样工作。只有这个地方才有这个问题;其他人工作得很好

为什么?


谢谢你的帮助。

我准备的声明也不起作用。@DorukAyar我的工作很好,但它的行为很奇怪。我对PHP并不陌生,但这是我第一次遇到这个荒谬的问题。我确实没有太多地使用MySQL,但我第一次使用MySQL,它不起作用。遵循我的代码,它工作得很好。
bind param
正在使用引用,所以请使用
$productQuantity=intval($productQuantity)
beforemine prepared语句也不起作用。@DorukAyar-Mine工作得很好,但行为怪异。我对PHP并不陌生,但这是我第一次遇到这个荒谬的问题。我确实没有太多地使用MySQL,但我第一次使用MySQL,它不起作用。遵循我的代码,它工作得很好。
bind param
正在使用引用,所以之前也要使用
$productQuantity=intval($productQuantity)