beginTransaction(); $query = "INSERT INTO message ('id', 'sender', 'type', 'book', 'paragraph', 'data', 'doc_id', 'time') VALUES (NULL,'{$username}',?,?,?,?,?,?)"; $stmt = $PDO->prepare($query); $arrMsgData = json_decode($data); foreach ($arrMsgData as $oneMsg) { $newData = array($oneMsg->type, $oneMsg->book, $oneMsg->para, $oneMsg->data, $oneMsg->docid, time()); $stmt->execute($newData); } // 提交更改 $PDO->commit(); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error - $error[2]
"; } else { } } $query = "select id from message where 1 order by id DESC limit 0,1"; $maxId = PDO_FetchOne($query); //查询相关文档的消息 echo ""; echo "maxid$maxId"; $query = "select * from message where \"doc_id\" = '$doclist' AND \"id\" > {$lastid} limit 0,10000"; $Fetch = PDO_FetchAll($query); $iFetch = count($Fetch); if ($iFetch > 0) { for ($i = 0; $i < $iFetch; $i++) { echo ""; echo "" . $Fetch[$i]["id"] . ""; echo "" . $Fetch[$i]["sender"] . ""; echo "" . $Fetch[$i]["type"] . ""; echo "" . $Fetch[$i]["data"] . ""; echo "" . $Fetch[$i]["doc_id"] . ""; echo ""; echo "0"; echo ""; } } echo "";