我必须表:
tb_document tb_sentence
================= ===========================================
|doc_id|document| | id | sentence_id |sentence | doc_id|
================= ===========================================
我想从中获取document
数据tb_document
。数据是文本,然后将数据解析成句子。我只需要为 tb_sentence 中的每个文档存储最多 50 个句子。
这是代码:
foreach ($content as $doc_id => $sentences){ //$content is variable that save document from tb_document
$i = 0;
foreach(preg_split('/\\.\\s*/', $sentences) as $current_sentence){
$q = mysql_query("INSERT INTO tb_sentence SET doc_id = {$doc_id}, sentence_id = {$i}, sentence = '{$current_sentence}'") or die(mysql_error());
$i<51; $i++;
}
}
但是,它仍然保存整个数据。请帮我。谢谢你 :)