PHP Developers Network
http://forums.devnetwork.net/

query with temporary table
http://forums.devnetwork.net/viewtopic.php?f=2&t=144371
Page 1 of 1

Author:  rosie [ Fri Oct 06, 2017 2:07 pm ]
Post subject:  query with temporary table

Hi,

I am new in php and I have a problem a push from your would be no refusal :p, my problem is when I execute the query in sql server its works normaly but when I execute its with php does not work empty result . thanks to helping me

here my code:

Syntax: [ Download ] [ Hide ]

$sql = "  

select t.Tan, SUM(s.TOP) as Top
into #TempEnj
from [Proses].[dbo].[CD_Dok] d
inner join [Proses].[dbo].[CD_Sar] s on(s.DOID = d.ID)
inner join [Proses].[dbo].[CT_Sa] t on (s.TANID= t.ID)

  where d.date ='2017-10-05'

   group by T.Tan

insert into #TempEnj values ('Enerji', (select sum(Enj) from [Proses].[dbo].[CD_Dok] where date ='2017-10-05'))
insert into #TempEnj values ('Sure', (select sum(Sure) from [Proses].[dbo].[CD_Dok] where date ='2017-10-05'))
select * from #TempEnj "
;




$stmt5  sqlsrv_query( $conn, $sql );
if( $stmt == false ) {
    if( ($errors = sqlsrv_errors() ) != null) {
        foreach( $errors as $error ) {
            echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
            echo "code: ".$error[ 'code']."<br />";
            echo "message: ".$error[ 'message']."<br />";
        }
    }
}


$tab[]= array();
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
    $tab[] = $row;


}  
var_dump($tab);


 

Author:  requinix [ Sat Oct 07, 2017 2:49 am ]
Post subject:  Re: query with temporary table

If sqlsrv_query allows you to run multiple queries then they probably need to be delimited by semicolons, and you'd probably need to use sqlsrv_next_result() to go between the two/four resultsets.

Author:  rosie [ Sat Oct 07, 2017 1:22 pm ]
Post subject:  Re: query with temporary table

hi,

you are reight , sqlsrv_next_result() fixed my problem thank you :)

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/