检查BLOB

时间:2017-12-07 15:45:15

标签: php mysql blob

我设置了一个包含2列的表(blob_table):blob_name,blob_file。

列blob_file默认设置为NULL,并与BLOB一起存储。

在用blob填充一些行之后,我尝试在下面运行PHP:

<?php

$con = new mysqli('localhost','root','root','database');
if ($con->connect_error) {die("error!");}

echo "<div><table><tr><th>Blob Not Yet Upload</th></tr>";

$sql = $con->prepare("SELECT blob_name FROM blob_table WHERE blob_file IS NULL");
$sql->execute();
$result = $sql->get_result();
while ($row = $result->fetch_assoc()) {
echo "<tr><td>".$row['blob_name']."</td></tr>";
} 
echo "</table></div>";
mysqli_close($con);
?>

它没有返回任何东西,为什么?我期待blob_file列中那些NULL的blob_name返回...

1 个答案:

答案 0 :(得分:0)

使用此

   <?php

    $con = new mysqli('localhost','root','root','database');
    if ($con->connect_error) {die("error!");}

    echo "<div><table><tr><th>Blob Not Yet Upload</th></tr>";

    $sql = $con->query("SELECT blob_name FROM blob_table WHERE blob_file = '' ");

    while ($row = $sql->fetch_assoc()) {
    echo "<tr><td>".$row['blob_name']."</td></tr>";
    } 
    echo "</table></div>";
    mysqli_close($con);
    ?>