0

以下の mysql コマンドは null の結果を返します。

PHPでこれを確認する方法

SELECT (sum(`money1`) - sum(`money2`)) as sm FROM `manfeatokasb`

以下のコードは正しくなく、null の結果をチェックできませんでした

if ($result['sm'] === null  )
{
    echo 'this command is return null result';
}
4

2 に答える 2

1

使用するis_null()

if (is_null($result['sm']))
{
    echo 'this command is return null result';
}
于 2013-03-17T19:49:33.390 に答える
0

mysql_num_rows を使用できます

if(mysql_num_rows($result) != 0){
     //code if "not null"
}else{
    //code if "null"
}
于 2013-03-17T21:30:48.983 に答える