0
如何用php查询mysql NULL
列变量?php mysql如何用php检查NULL列
我行表(例如):
1 ---- james ------ italy
2 ---- joyee ------ NULL
我从表中获取数组:
$rows[0] = array('name' => 'james', 'country' => 'italy');
$rows[1] = array('name' => 'joyee', 'country' => NULL);
但我的问题:
如何检查NULL数组元件:
foreach($rows as $row) {
if ($row['country'] == NULL) echo "country is null"; // not working
if ($row['country'] == '') echo "country is null"; // not working
if (is_null($row['country'])) echo "country is null"; // not working
if (empty($row['country'])) echo "country is null"; // not working
// what is solution? how to check null?
}
更新(的var_dump):
'country' => null
以小写字母试试null。 –
你可以用var_dump($ rows [1])更新你的文章吗? –
可能重复的[PHP检查NULL](https://stackoverflow.com/questions/1576243/php-check-for-null) –