Reputation: 691
What should be the logic for the function below?
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;
}
}
This is the function used to check if a field is empty. If the field is originally field and updated with the contents removed in a form the other function should insert a form but it is not inserting.
Upvotes: 1
Views: 175
Reputation: 2552
The query will return true if it can't match any rows, false otherwise:
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;
}
Upvotes: 1