Sum of oracle columns from php

0

I have this query from PHP , which does not return values but if I execute it from Oracle SQL Developer it shows me data.

    $sucursalesaño=[];
    $ventasaño=[];
    $query ='SELECT S.SUCURSAL , SUM(V.TOTAL_VENTAS)
            FROM T_VENTAS V, T_SUCURSAL S, T_TIEMPO T
            WHERE V.ID_TIEMPO= T.ID_TIEMPO AND T.AÑO=2016
            AND S.ID_SUCURSAL =V.ID_SUCURSAL AND V.ID_SUCURSAL IN (1,2,3,4,5,6)
            GROUP BY SUCURSAL';
    $stid = oci_parse($conn, $query);
    oci_execute($stid);
    while (($row = oci_fetch_array($stid, OCI_BOTH)) != false) 
      {
        array_push($sucursalesaño, $row[0]);
        array_push($ventasaño, $row[1]);
      }
    oci_free_statement($stid);

Without changing the time to make a query from a single table like the following if you show me information:

SELECT COLONIA,SUM(PRECIOFINAL) PFINAL from TDATOS where LOCATION_CODE=11174 and COLONIA IS NOT NULL GROUP BY COLONIA;

The only difference with the function is the query, they could help me

    
asked by Francisco Guillermo Herrera Ga 08.09.2017 в 18:14
source

1 answer

0

I would change OCI_BOTH to OCI_NUM (to be optimized), then give it a var_export ($ row) and I would put it twice as long in the while (! == false). With the var_export we see that it has $ row and from there we throw.

    
answered by 08.09.2017 в 22:20