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

Melanie Legault, Mrs melanie.legault2 at mcgill.ca
Thu Jan 16 11:15:23 EST 2020


Hello Rolando,

Sorry if I misled you on the wrong track. You can't use `in` using pselect() or pselectOne().
In order to use `in` you have to use run().


Mélanie


________________________________
From: loris-dev-bounces at bic.mni.mcgill.ca <loris-dev-bounces at bic.mni.mcgill.ca> on behalf of Rolando Acosta <rolando.acosta at cnbp.ca>
Sent: January 16, 2020 10:55
To: loris-dev at bic.mni.mcgill.ca <loris-dev at bic.mni.mcgill.ca>
Subject: [Loris-dev] Issue when trying to use "pselectOne" and "pselect" functions with an " IN " sql statement

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/415530e5/attachment.html>


More information about the Loris-dev mailing list