下面这个函数的逻辑应该是什么?
function check_empty($field){
$this->_params();
$db = $this->getDb();
$milestone = $db->select()
->from('milestone')
->where("$field IN ('')")
->where("name = ?", $this->milestone['name']);
$milestone_stmt = $db->query($milestone);
echo $milestone->__toString();
$milestone_result = $milestone_stmt->fetchAll();
if(count($milestone_result) > 0) {
return true;
} else {
return false;
}
}
这是用于检查字段是否为空的函数。如果字段最初是字段,并用表单中删除的内容进行更新,则其他函数应插入表单
但这不是插入。
最佳答案
如果查询无法匹配任何行,则返回true,否则返回false:
function check_empty($field) {
$this->_params();
$db = $this->getDb();
$milestone = $db->select()
->from('milestone')
->where("$field = ''")
->where("name = ?", $this->milestone['name']);
$milestone_stmt = $db->query($milestone);
//No query results means the field is not empty.
return $milestone_stmt === false;
}
关于php - 查询字段是否为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5509136/