I’m having some trouble implementing (or understanding) how to bind parameters to prepared statements.
Assuming TableA, TableB, and TableC have schemas and models defined, but no relationships:
$q = $modx->newQuery('TableA');
$q->select('TableA.*, TableB.*, TableC.*');
$q->leftJoin('TableB', 'TableB', array(
'TableC.someid:IN' => ':str1',
'TableC.somekey:=' => $somekey
));
$q->prepare();
echo $q->toSQL();
My goal is to substitute
:str1 with the string ’
TableB.csvids’ (a comma-delimited list of IDs).
I’ve tried different kinds of bindings, including:
$q->leftJoin('TableB', 'TableB', array(
'TableC.someid:IN' => ':str1',
'TableC.somekey:=' => $somekey
), null, array(':str1', 'TableB.csvids'));
$q->bind(':str1', 'TableB.csvids');
$q->prepare(array(':str1', 'TableB.csvids'));
But the echo’ed SQL statement always shows [tt]:str1[/tt] being parsed as 0. Ideally I would like to apply this query to a [tt]getObject[/tt] or [tt]getCollection[/tt] rather than implicitly execute the statement.
What am I missing?