When using PDO::FETCH_COLUMN in a while loop, it's not enough to just use the value in the while statement as many examples show:
<?php
while ($row = $stmt->fetch(PDO::FETCH_COLUMN)) {
print $row;
}
?>
If there are 5 rows with values 1 2 0 4 5, then the while loop above will stop at the third row printing only 1 2. The solution is to either explicitly test for false:
<?php
while (($row = $stmt->fetch(PDO::FETCH_COLUMN)) !== false) {
print $row;
}
?>
Or use foreach with fetchAll():
<?php
foreach ($stmt->fetchAll(PDO::FETCH_COLUMN) as $row) {
print $row;
}
?>
Both will correctly print 1 2 0 4 5.