Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Core: Candidate] Fix getFirstVisit method #4075

Merged
merged 17 commits into from
Jan 28, 2019
13 changes: 5 additions & 8 deletions php/libraries/Candidate.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -613,22 +613,19 @@ class Candidate
/**
* Returns first visit for a candidate based on Date_visit
*
* @return string The visit label for the candidate's first visit
* @return string|null The visit label for the candidate's first visit
*/
public function getFirstVisit()
{
$factory = NDB_Factory::singleton();
$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
WHERE CandID = :cid AND Date_visit IS NOT NULL
ORDER BY Date_visit, ID ASC LIMIT 1";
$where = array('cid' => $candID);
$vLabel = $db->pselectOne($query, $where);

$vLabel = $db->pselectCol($query, $where)[0] ?? null;
davidblader marked this conversation as resolved.
Show resolved Hide resolved
return $vLabel;
}

Expand Down