I'm writing to you today because i've got question about the Method FetchAll() in PHP.
I'm currently developing Web API and I would like to set GetSomething() method using Json_encode.
The thing is when I m using it those returning fields as String type.. I found couple way to fix it as JSON_NUMERIC_CHECK but i feel like missing something.. May be should I instance new object and call the constructor before returning json_encode() ?
Thanks for reading me ! :)
public function GetProduit()
{
$ReqClient = "SELECT * FROM dbo.Produit";
$MailVerif = $this->connexion->prepare($ReqClient);
$MailVerif->execute(array());
$result = $MailVerif->fetchAll();
if (!$result) {
throw new Exception('Nothing set');
}
echo json_encode($result, JSON_NUMERIC_CHECK);
}