1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| include 'sqlserver_vars.php';
$Requete = $_GET['Requete'];
if($Requete != NULL and $Requete != "")
{
$connection = odbc_connect("Driver={SQL Server};Server=$server;Database=$db",$dbUsername,$dbPassword) ;
$Resultat= odbc_exec($connection, $Requete);
$NbrChamps = odbc_num_fields($Resultat);
$data = array();
while($itemRow = odbc_fetch_row($Resultat))
{
$lig = array();
for($i=1;$i<=$NbrChamps;$i++)
{
$val = utf8_encode(odbc_result($Resultat,$i ));
array_push($lig,$val);
}
array_push($data,$lig);
}
echo json_encode($data);
odbc_close($connection);
} |
Partager