0

以下是我的代码

//FIRST UPDATE QUERY
$firstupdatequery = "UPDATE `register` SET suser ='1' ";
//Second UPDATE QUERY
$updater = "UPDATE `register` SET suser ='$suser',steamleader ='$steamleader',ipdate ='$ipdate',customer ='$customer',cperson1 ='$cperson1',mobile1 ='$mobile1',phone ='$phone',fax ='$fax',email ='$email',website ='$website',pincode ='$pincode',state ='$state',city ='$city',address ='$address',status ='$status',data_resource ='$data_resource',comments ='$comments',data_status ='$data_status',followup_date ='$followup_date',last_followup_date ='$last_followup_date',last_comment ='$last_comment',data_assign ='$data_assign',bank_id = '$bank_id' WHERE id = ".$getid."";

$exequery = $conn->query($updater);
if($exequery){
  if(mysqli_affected_rows($conn) > 0){
    //insert for followup recored
    echo "<pre>";
    print_r($conn);
    echo $conn->affected_rows;
    exit;
    //And than I am running another insert query here

此代码显示是否更新了任何行,因此我运行另一个插入查询。但问题是当我按下按钮而不更改任何值时,mysqli 对象affected rows计数仍为 1。

mysqli Object
(
    [affected_rows] => 1

为什么这个计数1即使我没有改变任何值。*

注意:我正在更新此代码上方的一行

4

1 回答 1

2

有一个技巧,我会称之为肮脏的,但我不知道这样做的更清洁的方法

list($matched, $changed, $warnings) = sscanf($conn->info, "Rows matched: %d Changed: %d Warnings: %d");
于 2018-03-26T10:57:44.220 回答