Good afternoon,
The following code returns me in json ... but it's in pdo .. what would it be like in adodb?
$users = $stmt->fetchAll(PDO::FETCH_OBJ);
echo '{"users": ' . json_encode($users) . '}';
edit:
I tried this, but it does not work:
if($db){
$stmt = $db->Execute($sql);
$retorno = array();
while(!$stmt->EOF){
$retorno[] = $stmt->fields;
$stmt->MoveNext();
}
echo '{"retorno": ' . json_encode($retorno) . '}';
}
What I tried to do in the above code was to go through the recordset with the data of the select, inserting this data into the array. and transform the array into json ..
I get the empty json .. but the query, by the testo I made, returns me data
json's result:
{"retorno": }
result of print_r ($ return);
Array ( [0] => Array ( [0] => [VENDA] => [1] => 1 [PRODUTO] => 1 ) )
edit:
if($db){
$stmt = $db->Execute($sql);
$retorno = array();
while($res = $stmt->GetArray()){
$retorno[] = $res;
}
echo '{"retorno": ' . json_encode($retorno) . '}';
}
solution!
if($db){
$stmt = $db->Execute($sql);
$retorno = $stmt->GetArray();
//var_dump($retorno);
echo '{"retorno": ' . json_encode($retorno) . '}';
if( $jret = json_encode($retorno) ){ echo "nice"; } else{ echo "Fail"; }
}
however ... my data has a special character like "ç" and json is not accepting that .. ie .. is not accepting utf-08 .. when removing the special characters json works ...
Does anyone know how to solve this?