I'm getting nowhere with MS Sql and some php queries.
function getBillet($idBillet) {
$connection = getBdd();
$sql = 'select BIL_ID as id, BIL_DATE as date,
BIL_TITRE as titre, BIL_CONTENU as contenu from t_billet
where BIL_ID=?';
$billet = $connection->prepare($sql);
$billet->execute(array($idBillet));
if ($billet->rowCount() == 1)
return $billet->fetch();
else
throw new Exception('Aucun billet ne correspond à l\'identifiant' . $idBillet . ' ');
}
This one is not working, i'm trying to fetch the row with the ID inserted on parameter. The connection to the database works fine, but I can't get the query to work. Especially since all the information on google is about MySQL but very few about MS SQL. This one works fine for example :
function getBillets() {
$connection = getBdd();
$sql = 'select BIL_ID as id, BIL_DATE as date,
BIL_TITRE as titre, BIL_CONTENU as contenu from t_billet
order by BIL_ID desc';
$result = $connection->query($sql);
$resultat = $result->fetchAll();
return $resultat;
}
Thanks in advance.