0

我正在使用 Zend 2 使用 select 查询,如下所示。

我需要检查上述结果是否返回 NULL(即如果电子邮件列为 NULL)。

$checkEmailId = "Select EmailId from UsersNew where HashedUid='".$newUserId."'";
$Emailquery = $this->getUsersNewTable()->checkEmailnull($checkEmailId);

if(Email is Null)
{
   //EMail null
}
else{
   //EMail not null
}

模型文件:

public function checkEmailnull($sql){
        $data = $this->tableGateway->getAdapter()->driver->getConnection()->execute($sql);
        return $data;
}
4

1 回答 1

1

这里“ $Emailquery”是ResultInterface

 $checkEmailId = "Select EmailId from UsersNew where HashedUid='".$newUserId."'";
 $Emailquery = $this->getUsersNewTable()->checkEmailnull($checkEmailId);

//now to get the current record 
$record = $Emailquery->current();

if(is_null($record["EmailId"]))
{
   //EMail null
}
else{
   //EMail not null
}
于 2019-01-11T14:48:57.483 回答