我正在使用Zend 2进行选择查询,如下所示。
我需要检查以上结果是否返回NULL(即,如果Email列为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;
}
答案 0 :(得分: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
}