拜托,谁能告诉我这里我做错了什么?我只是从表中检索结果然后将它们添加到数组中.一切都按预期工作,直到我检查一个空的结果...
这将获得匹配,将其添加到我的数组并按预期回应结果:
$today = date('Y-m-d', strtotime('now'));
$sth = $db->prepare("SELECT id_email FROM db WHERE hardcopy = '1' AND hardcopy_date <= :today AND hardcopy_sent = '0' ORDER BY id_email ASC");
$sth->bindParam(':today',$today, PDO::PARAM_STR);
if(!$sth->execute()) {
$db = null ;
exit();
}
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$this->id_email[] = $row['id_email'] ;
echo $row['id_email'] ;
}
$db = null ;
return true ;
Run Code Online (Sandbox Code Playgroud)
当我尝试检查空结果时,我的代码返回'empty',但不再产生匹配结果:
$today = date('Y-m-d', strtotime('now'));
$sth = $db->prepare("SELECT id_email FROM db WHERE hardcopy = '1' AND hardcopy_date <= :today AND hardcopy_sent = …
Run Code Online (Sandbox Code Playgroud)