Skip to content

Commit

Permalink
[Core: Candidate] Fix getFirstVisit method (#4075)
Browse files Browse the repository at this point in the history
Update query in Candidate getFirstVisit method to fix exception about using pselectRow on a query with multiple rows.
  • Loading branch information
davidblader authored and driusan committed Jan 28, 2019
1 parent 18b052b commit 6f92f69
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions php/libraries/Candidate.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class Candidate
function getProjectTitle(): string
{
$ProjectList = Utility::getProjectList();
return $ProjectList[$this->getProjectID()];
return $ProjectList[$this->getProjectID()] ?? '';
}

/**
Expand Down Expand Up @@ -638,15 +638,13 @@ class Candidate
$db = $factory->database();

$candID = $this->getCandID();

$query = "SELECT Visit_label
FROM session s JOIN candidate c ON (c.CandID = s.CandID)
WHERE c.CandID=:cid AND Date_Visit IS NOT NULL
ORDER BY Date_Visit";
$query = "SELECT Visit_label FROM session
LEFT JOIN candidate USING (CandID)
WHERE CandID = :cid AND VisitNo = 1
AND Entity_type <> 'Scanner'";
$where = array('cid' => $candID);
$vLabel = $db->pselectOne($query, $where);

return $vLabel;
$result = $db->pselectOne($query, $where);
return $result ?? '';
}

/**
Expand Down

0 comments on commit 6f92f69

Please # to comment.