try casting:
'id' => (string) $id,
'scope' => (int) $scope,
'endNumber' => (int) $endNumber
I have a query:
WHERE tblSU.Site = :id AND tblSU.SUTypCode != 'GEN' AND tblSU.SUNum >= :scope AND tblSU.SUNum <= :endNumber
And then I run it:
$studyUnitsSql = DB::getPdo()->prepare($studyUnitsSql);
$studyUnitsSql->setFetchMode(\PDO::FETCH_OBJ);
$studyUnitsSql->execute([
'id' => $id,
'scope' => $scope,
'endNumber' => $endNumber
]);
$studyUnits = collect($studyUnitsSql->fetchAll());
This issue is that $id needs quotes but $scope and $endNumber also get passed with quotes ("100") and I need them without quotes(100) while retaining the quotes for $id. How do I do that?
I need my SQL to work like:
tblSU.SUNum >= 100 AND tblSU.SUNum <= 200
If I have quotes around the numbers I do not get the correct results.
Thanks!
@stanhook oh, okay. Did you try bindValue to set the type?
$studyUnitsSql->setFetchMode(\PDO::FETCH_OBJ);
$sql->bindValue('id', $id, PDO::PARAM_STR);
$sql->bindValue('scope', $id, PDO::PARAM_INT);
$sql->bindValue('endNumber', $endNumber, PDO::PARAM_INT);
$studyUnitsSql->execute();
Please or to participate in this conversation.