$iCurrPara){
//echo "new paragraph
";
$iWord=0;
if($i>2){
//echo "上一段结束
";
if(strlen(trim($sent))>0){
$end = $wordlist[$i-1][16];
$arrSent[]=array($book,$iCurrPara,$begin,$end,mb_strlen($sent_real,"UTF-8"),$wordcount,$sent,$sent_real,getWordEn($sent_real));
//echo "end={$end}
";
//echo "[{$iCurrPara}-{$begin}-{$end}]({$wordcount})
{$sent}
{$sent_real}
".getWordEn($sent_real)."
";
}
$iCurrPara=$wordlist[$i][3];
//下一段开始
if($wordlist[$i][6]!=".ctl."){
$sent=$wordlist[$i][4]." ";
if($wordlist[$i][5]=='"'){
$sent_real="";
}
else{
$sent_real=$wordlist[$i][5];
}
$wordcount=1;
}
else{
$sent="";
$sent_real="";
$wordcount=0;
}
$begin = $wordlist[$i][16];
$iSent++;
continue;
}
$iCurrPara=$wordlist[$i][3];
}
$isEndOfSen=false;
if($i0){
$end = $wordlist[$i][16];
$arrSent[]=array($book,$iCurrPara,$begin,$end,mb_strlen($sent_real,"UTF-8"),$wordcount,$sent,$sent_real,getWordEn($sent_real));
//echo "end={$end}
";
//echo "[{$iCurrPara}-{$begin}-{$end}]({$wordcount})
{$sent}
{$sent_real}
".getWordEn($sent_real)."
";
$sent="";
$sent_real="";
$iSent++;
$begin = $wordlist[$i][16]+1;
$wordcount=0;
}
$iWord++;
}
if(strlen(trim($sent))>0){
$end = $wordlist[count($wordlist)-1][16];
$arrSent[]=array($book,$iCurrPara,$begin,$end,mb_strlen($sent_real,"UTF-8"),$wordcount,$sent,$sent_real,getWordEn($sent_real));
//echo "end={$end}
";
//echo "[{$iCurrPara}-{$begin}-{$end}]({$wordcount})
{$sent}
{$sent_real}
".getWordEn($sent_real)."
";
}
}
else{
echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
}
// 开始一个事务,关闭自动提交
PDO_Connect("sqlite:$db_file");
$PDO->beginTransaction();
$query="INSERT INTO pali_sent ('id','book','paragraph','begin','end','length','count','text','real','real_en') VALUES (NULL,?,?,?,?,?,?,?,?,?)";
$stmt = $PDO->prepare($query);
foreach($arrSent as $oneParam){
$stmt->execute($oneParam);
}
// 提交更改
$PDO->commit();
if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
$error = PDO_ErrorInfo();
echo "error - $error[2]
";
$log=$log."$from, $FileName, error, $error[2] \r\n";
}
else{
$count=count($arrSent);
echo "updata $count recorders.";
}
$myLogFile = fopen(_DIR_LOG_."insert_sent.log", "a");
fwrite($myLogFile, $log);
fclose($myLogFile);
?>
=$to){
echo "齐活!功德无量!all done!
";
}
else{
echo "";
echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
}
?>