[Loris-dev] Issue when trying to use "pselectOne" and "pselect" functions with an " IN " sql statement

Rolando Acosta rolando.acosta at cnbp.ca
Thu Jan 16 10:55:27 EST 2020


Hi LORIS team,

A while ago I faced the following issue in one of the PRs I was working on:

/////////////////////////////////////////

The structure:

$recruitmentStartDate = $DB->pselectOne(
    "SELECT MIN(Date_registered)
     FROM candidate

* WHERE RegistrationCenterID IN (:Sites)",    array('Sites' => implode(",",
array_keys($list_of_sites)))*
);

Doesn't seem to be working for me. Only the first element of the array
$list_of_sites is been passed to the IN SQL clause. Not sure if I'm using
correctly this way. For the moment I write it as:

$recruitmentStartDate = $DB->pselectOne(
    "SELECT MIN(Date_registered)
     FROM candidate

*WHERE RegistrationCenterID IN (" . $sitesString . ")",    array()*
);

//////////////////////////////////////////////////


I'm having the same behavior with the function *pselect(string $query,
array $params): array*
from the *class Database*.

I'm wondering if you could take a look and see if there is a way to pass an
array as one of the elements in the *$params* array? The issue rises when
need to do an IN statement as part of the query.

Cheers,
Rolando Acosta (CHU Sainte-Justine)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.bic.mni.mcgill.ca/pipermail/loris-dev/attachments/20200116/1831a3d9/attachment.html>


More information about the Loris-dev mailing list