I try to run a query in php but have some troubles
When I don't use placeholders, it works
But when I use the placeholder (so change $deRow to $deRowP wich hold the id of the current row) it won't run correctly anymore
What am I doing wrong here?
Greetings,
Filip
When I don't use placeholders, it works
PHP:
$deRowP = '{rowid}';
$deRow = 42;
$user = JFactory::getUser();
$userid = $user->get('id');
$mydb = JFactory::getDbo();
$myquery = $mydb->getQuery(true);
$myquery
->select(array('Naam_v as pupil', 'if(i.id is null,"Nee","Ja") as Ingeschreven'))
->from($mydb->quoteName('bc_leerlingen', 'll'))
->join('LEFT', $mydb->quoteName('bc_inschrijvingen', 'i') . ' ON (' . $mydb->quoteName('i.leerling_id') . ' = ' . $mydb->quoteName('ll.id') . ') and ('.$mydb->quoteName('i.activiteit_id') . ' = '.$mydb->quote($deRow).')')
->where($mydb->quoteName('ll.parent_id').' = '.$mydb->quote($userid));
$mydb->setQuery($myquery);
$myrows = $mydb->loadAssocList();
echo '*'.$deRowP.'*'.$deRow.'*'.$userid.'*<br>'.$myquery.'<br>';
print_r($myrows);
*42*42*268*
SELECT Naam_v as pupil,if(i.id is null,"Nee","Ja") as Ingeschreven FROM `bc_leerlingen` AS `ll` LEFT JOIN `bc_inschrijvingen` AS `i` ON (`i`.`leerling_id` = `ll`.`id`) and (`i`.`activiteit_id` = '42') WHERE `ll`.`parent_id` = '268'
Array (
[0] => Array ( [pupil] => xxx [Ingeschreven] => Ja )
[1] => Array ( [pupil] => yyy [Ingeschreven] => Nee ) )
But when I use the placeholder (so change $deRow to $deRowP wich hold the id of the current row) it won't run correctly anymore
As you see, the first pupil (xxx) has now [Ingeschreven] => Nee where it should be "Ja"*42*42*268*
SELECT Naam_v as pupil,if(i.id is null,"Nee","Ja") as Ingeschreven FROM `bc_leerlingen` AS `ll` LEFT JOIN `bc_inschrijvingen` AS `i` ON (`i`.`leerling_id` = `ll`.`id`) and (`i`.`activiteit_id` = '42') WHERE `ll`.`parent_id` = '268'
Array (
[0] => Array ( [pupil] => xxx [Ingeschreven] => Nee )
[1] => Array ( [pupil] => yyy [Ingeschreven] => Nee ) )
What am I doing wrong here?
Greetings,
Filip