Let me know if that solves your problem if you would be so kind... I am sure it will but I just want to make sure.
Jas


Jas wrote:

Have you tried setting a limit on your MySQL insert and update statements to limit the amount trying to be processed?

Haseeb Iqbal wrote:

hi,
i need to update a mysql table with a dbf file, the dbf file contains more then 160000 records. i knew that the script will not be able to update 160000 records in 1 go so i am refreshing the page after speacific no of records. but still the same problem. the script timeout.i tried changing the timeout limit to 300 secs but to noavail. i am pasting the code here.plz take a look may by you can tell me what i am doing wrong



<? define("strPath","./");

define("_MySqlEnable",TRUE);

set_time_limit(0);

require_once(strPath."paths.php");

$strDBName=strPath."uploads/".Date("d-m-Y")."-products.dbf";
$DBPointer=dbase_open($strDBName,0) or die("Cannot open file for reading");
$nNoOfRecs=dbase_numrecords($DBPointer);
$nLoopBreak=1500;
$nConn=GetCon();


if (empty($nLoopStart)) { $nLoopStart=1; }

 if ($nNoOfRecs > $nLoopBreak)
  {
   $nLoopTill=$nLoopStart + $nLoopBreak;
   $nFinal=FALSE;
  }
 else
  {
   $nLoopTill=$nLoopBreak;
   $nFinal=TRUE;
  }

 for ($nCount=$nLoopStart;$nCount<=$nLoopTill;$nCount++)
  {
   $arrData=dbase_get_record($DBPointer,$nCount);

   $GRP=CheckString($arrData[0]);
   $CAT=CheckString($arrData[1]);
   $SUB=CheckString($arrData[2]);
   $VEND_CODE=CheckString($arrData[3]);
   $MANU_PART=CheckString($arrData[4]);
   $PART_NUM=CheckString($arrData[5]);
   $DESCR=CheckString($arrData[6]);
   $COST=CheckString($arrData[7]);
   $RETAIL=CheckString($arrData[8]);
   $QTY=CheckString($arrData[9]);
   $LIST_PRICE=CheckString($arrData[10]);
   $EFF_DATE=CheckString($arrData[11]);
   $TECH_FAX=CheckString($arrData[12]);
   $STATUS=CheckString($arrData[13]);
   $UPC=CheckString($arrData[14]);

$strQuery="SELECT * FROM products WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'";
$nConn->doQuery($strQuery);


if ($nConn->cntResult()==0)
$strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products.manu_part,products.part_num,products.desc,products.cost,products.retail,products.qty,products.list_price,products.eff_date,products.tech_fax,products.status,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','".$PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRICE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."')";



$strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products.manu_part,products.part_num,products.desc,products.cost,products.retail,products.qty,products.list_price,products.eff_date,products.tech_fax,products.status,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','".$PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRICE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."' LIMIT 200)";


else
$strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$RETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$TECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'";

$strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$RETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$TECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'LIMIT 200";



//echo "<br>nCOunt - > $nCount -----".$strQuery;
$nConn->doQuery($strQuery);
}
$nCount++;
$nLoopStart=$nCount;
if ($nFinal==FALSE)
{
//1500 records updated so refresh the page
?>
<meta http-equiv="Refresh" content="2; URL=mypage.php?nLoopStart=<?=$nLoopStart;?>">
<?
}
else
{
// all records updated so redirst to calling page.
?>
<meta http-equiv="Refresh" content="2; URL=main.php?nStatus=1">
<?
} ?>


Haseeb


That might help out with the timeouts too.
Jas

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to