1.数据库字段值为null利用setInc方法无法直接写入,先判断是否为空,再写入。

 

 if($points->add($dataList)){
    $user=M('cuser');
     $null=$user->where(array('id'=>$userid))->field('points')->find();
      //if(empty($null['points'])){    //判断数据库字段是否为null  不支持0
    if(is_null($null['points'])){    $user->where(array('id'=>$userid))->save($data); }else{ $user->where(array('id'=>$log))->setInc('points',5); }   $status=1; }

 数据库字段值为null利用setInc方法无法直接写入

 2.*********************楼下评论**********************************

<?php
 $null="0";
   if(empty($null)){                                
        echo 1;
       }else{
        echo 2;
      }

输出1,说明0也为null 用is_null.上面错误改正!

3.

<?php
 $null="0";
   if(is_null($null)){                                
        echo 1;
       }else{
        echo 2;
         }

echo 2;

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-10
  • 2022-12-23
  • 2021-08-03
猜你喜欢
  • 2022-12-23
  • 2021-11-26
  • 2021-06-04
  • 2021-10-31
  • 2022-12-23
  • 2022-01-07
  • 2021-12-30
相关资源
相似解决方案