I'm running the following query in postgres:
SELECT (SUM(g.grade_days_late) - SUM(s.ex_late_days)) as used_late_days
FROM grades as g
LEFT JOIN ( SELECT * FROM late_day_exceptions )
as s on s.ex_rubric_id = g.rubric_id and s.ex_student_rcs=g.student_rcs
WHERE g.student_rcs='?' AND g.status=1 AND g.rubric_id < ?
with the following commands:
$statement = Database::$link->prepare($query);
$statement->execute($parameters);
$parameters is equal to:
array (size=2)
0 => string 'test' (length=7)
1 => int 6
and I get the following error:
PDOException: SQLSTATE[42P18]: Indeterminate datatype: 7 ERROR: could not determine data type of parameter $2
I run the query directly against the database replacing the two ? with the stuff in $parameters and it works fine. If I add ' around the second parameter, the query returns nothing (yet still returns the proper answer if run directly against it with the values inserted).
I really have no idea what's going on here or why I'm getting an error. (Database is an open PDO connection, no issues there).