I have a function that queries a firebird 2.5 database to return a sum of a column.
If I execute this select in a query manager all works fine, but the sum result from php code is wrong.
For example the result value from query manager is 1.205,55 and from php code is 699.785.495,12.
The value of the year colum is correct and the lines returned are correct.
This is the code
$db = getDB();
$rows = array();
$sth = $db->prepare("select Sum(D.total) as TOT, D.YEAR from DOCUMENTS D
where D.CUST = :custid
GROUP BY D.YEAR ");
$custid = $request->getAttribute('custid');
$sth->bindParam(':custid', $custid, PDO::PARAM_INT);
$sth->execute();
$count = 0;
while ($row = $sth->fetch (PDO::FETCH_OBJ)) {
$totval = array(
'year' => $row->YEAR,
'total ' => number_format($row->TOT, 2, ',', '.')
);
array_push($rows, $totval);
$count++;
}
I think that the error may be related to firebird's dll but the php version is recent (5.6.23) and the firebird dll is loaded properly without any error message.
I made many tests but I can not fix it.
Thanks in advance!
UPDATE 01/09/16 This problem occurs only with columns of "NUMERIC" type; with columns "COMPUTED BY" the error does not occur.
SOLVED 02/09/16 I've changed the component to manage firebird database from PDO_FIREBIRD to Firebird/InterBase Functions and all works fine. The value returned from the query of NUMERIC colums is correct. Probably the PDO_firebird made access to the database with dialect 1 because this is an old problem solved into PDO_firebird.