I have a problem with the rowCount() in this code:
$sqlLoc= "
DECLARE @Data2 AS DATE;
SET @Data2 = CONVERT(DATE,CONVERT(date, '$dataFine'), 102);
DECLARE @Data1 AS DATE;
SET @Data1 = CONVERT(DATE,CONVERT(date, '$dataInizio'), 102);
SELECT noteincassi.CodLocale,Insegna,Citta
FROM [Edera].[dbo].[NoteIncassi]
JOIN edera.dbo.AnagraficaLocali ON AnagraficaLocali.CodLocale=NoteIncassi.CodLocale
WHERE DataIncasso >= @Data1 AND DataIncasso <= @Data2 AND tipoincasso = '6' AND sospeso = 0
GROUP BY noteincassi.CodLocale,insegna,Citta
ORDER BY Insegna";
$queryLoc = $conn->prepare($sqlLoc,array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$queryLoc->execute();
echo $numero=$queryLoc->rowCount();
echo "<h1>MEDIA INCASSI DAL ".date('d-m-Y',strtotime($dataInizio))." AL ".date('d-m-Y',strtotime($dataFine))."</h1>";
$id=0;
while($resultLoc=$queryLoc->fetch()){
It will print -1, but the fecth is working and rows are returned, so the rest of the code is working fine, it's only the rowCount() and I don't understand why.
Thank you