[英]Query sql db and create array
I am using the below code to pull all the product codes that have a NULL value on ImageURL row 我正在使用以下代码来提取ImageURL行上具有NULL值的所有产品代码
$db = new PDO($dsn, $user, $pass);
$stmt = $db->query('SELECT f.ProductCode FROM Flat_table f WHERE f.ImageURL IS NULL');
$noImageProducts = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
But the $noImageProducts is empty even if i know that i have Products with no url in the ImageURL field. 但是$ noImageProducts是空的,即使我知道我在ImageURL字段中没有URL的Products。
there is a difference between empty string and NULL. 空字符串和NULL之间有区别。 Try this 尝试这个
SELECT f.ProductCode FROM Flat_table f WHERE f.ImageURL=''
if this query returns some value that means ImageURL values are not null. 如果此查询返回某个值,则表示ImageURL值不为null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.