dream890110 2014-10-18 21:30
浏览 84

为什么php $ mysqli-> affected_rows在行受影响时返回0?

For my following sql update query I need to get the number of affected rows. With $mysqli->affected_rows, I am getting 0 rows affected but while I check database, data are being updated. I ran the same query from phpMyAdmin which returns the number of affected as expected but my PHP is returning just 0; Any idea where I messed up?

print_r($sql);
// $sql=  UPDATE `f`.`air_pax`  SET `pax_type`='SRC'  , `pax_name`='PAUL/SATTYAJ MSTR(CHD/05NOV04)'  , `fare`='198'  , `c_discount`='1'  , `c_charge`='30'  , `tax`='20'  , `invoice`='247'  , `v_invoice`='ghi'  , `gross_fare`='150'  , `commission`='10'  , `v_charge`='50'  , `apc`='1'  , `t_charge`='5'  , `remarks`='rem 3'  , `cost_per_pass`='212.5'  WHERE `air_pax`.`serial`='5'  LIMIT 1 

if($result = $mysqli->query($sql)){
    var_dump($mysqli->affected_rows); // this returns 'int 0'

    if($mysqli->affected_rows == 1){
        return TRUE;
    } else{
        return FALSE;
    }
}

I know that if no changes are there, then number of affected rows will be 0; My [SERVER_SOFTWARE] => Apache/2.4.9 (Win32) PHP/5.5.12 .

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)