简体   繁体   English

Zend 2检查选择查询是否返回NULL

[英]Zend 2 check if select query returned NULL

I am using select query using Zend 2 like below. 我正在使用使用Zend 2的选择查询,如下所示。

I need to check if the above result returned NULL (ie) if the Email column is NULL). 我需要检查以上结果是否返回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
}

Model file: 模型文件:

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

Here " $Emailquery " is ResultInterface 这里的“ $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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM