I am working on a script that calls some SP's on a Microsoft SQL server. The procedures are running fine, but what I'm trying to do is have a while loop run while the procedure is generating the file (pdf report). Then when that file exists it should go to the next in the foreach loop. For some reason when I run it with test files it works fine, but when I do it with the actual stored procedures the first file is generated and my script moves on to the second, which is also generated by the Microsoft stored procedure, but the PHP script never recognizes that the file is on the server (which I see as being generated) and the script never moves on from the second file. Could this have anything to do with max_execution_time?
$db->select(payroll);
$locations = $db_ms->get_results("SELECT location_code FROM tblloc");
foreach ($locations as $val) {
$location = trim($val->location_code);
$path = '\\\tc-fp1\reports$\##LOCATION##\Payroll\\';
$linuxpath = '/var/www/html/system/intranet/reports/##LOCATION##/payroll/';
$cats = array('labordistpath' => array('name' => 'LaborDist.pdf','id' => '1021'),
'masterctlpath' => array('name' => 'MasterCtl.pdf','id' => '1023'),
'payregisterpath' => array('name' => 'PayRegister.pdf','id' => '1025'));
$db_ms->query("update dbopt set opt_value = '$location' where id = 'Location'");
foreach ($cats as $subkey => $subval) {
$fullpath = str_replace('##LOCATION##',$location,$path) . $subval['name'];
$fulllinuxpath = str_replace('##LOCATION##',$location,$linuxpath) . $subval['name'];
$db_ms->query("update dbopt set opt_value = '$fullpath' where id = '$subkey'");
$db_ms->query("exec PDS_ES_SchedJob 0,'','PDSADMIN',null,'A','PRGM_ID=" . $subval['id'] . "'");
echo $location . " -- " . $subval['name'] . " Is being generated";flush();
while (filesize($fulllinuxpath) < 1) {
echo '.';flush();sleep(5);
}
echo " DONE!<BR>";flush();
}
}