SELECT field1
This selects one column, namely field1
FROM testTable
The table to fetch field1 from
WHERE field2 = 1000
But only get field1 from the rows where field2 equals 1000. You claim that field2 has no value, so no rows would be fetched at all.
// Since field2 is supposed to be empty, nothing is retrieved from the db, so $row is false the first time.
while($row = $testing->fetchRow(MDB2_FETCHMODE_ASSOC)) {
// As explained above, each row is array('field1' => value_from_db)
foreach($row as $key => $value)
{
// so, you only deal with 'field1', and that one is not supposed to be empty.
if(empty($value))
{
echo "worked";
}
else
{
echo "didn't work";
}
}
}