>>90
あんまスマートじゃないけど許してね
たとえばこんな感じ
$row = $stmt->fetch();
if (false === $row) return ;
do {
//処理
} while($row = $stmt->fetch());