phpメモっていうかSQLのメモ。
$sql = "SELECT NULLIF(A,0) FROM AAA WHERE ID = 'BBB';";
$result = mysql_query($sql, $link) or die($sql);
→ 対象が存在しなければresultはNullになると思ってた。
$a = 0;
$sql = "SELECT NULLIF(A,0) AS A FROM AAA WHERE ID = 'BBB';";
$result = mysql_query($sql, $link) or die($sql);
while($row = mysql_fetch_array($result)){
$a = $row['A'];
}
$aは0ではなくNull
is_null関数で対処
if(is_null($a)){ $a = 0; }
phpむずい。
スコアタ開催中です。
http://snowcat3104.myvnc.com/LSP_SA/index.php