I would like to ignore the where
clause by setting the sql which needs to ignore the where
clause in another variable.
But when I try to run it nothing is shown.
When I remove the sql variable "$test"
and set the join within the $requete
. Then it will work but doesnt ignore the where clause:
<?php
// List of events
$json = array();
// Query that retrieves events
$requete = " SELECT distinct `evenementontvanger`.`idEvent`,`evenementontvanger`.`idProject`,`evenementontvanger`.`idKlant`,
`evenement`.`id`,`evenement`.`title`,`evenement`.`start`,`evenement`.`startdate`,`evenement`.`starttime`,
`evenement`.`end`,`evenement`.`enddate`,`evenement`.`endtime`,`evenement`.`description`,`evenement`.`color`
FROM `evenement` LEFT JOIN `evenementontvanger` ON `evenementontvanger`.`idEvent` = `evenement`.`id` WHERE `idEvent`=`evenement`.`id`";
$test ="LEFT JOIN `Werknemer` ON `Werknemer`.`idWerknemer`=`evenementontvanger`.`idWerknemer`";
// connection to the database
try {
$bdd = new PDO('mysql:host=localhost;dbname=blackboks-calendar', 'calendar-boks', '19xantia');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
// Execute the query
$resultat = $bdd->query($requete,$test) or die(print_r($bdd->errorInfo()));
// sending the encoded result to success page
echo json_encode($resultat->fetchAll(PDO::FETCH_ASSOC));
?>