<?php
require_once dirname(dirname(__FILE__)) . '/init.php';

$sql = 'SELECT * FROM bookposts LIMIT 3611532,200000';
$query = $db->query($sql);

$mongo = new Mongo();
$mdb = $mongo->selectDB('book');
$collect = $mdb->selectCollection('bookposts');

while ($row = $db->getArr($query))
{
    $pid = $row['bookpostsid'];
    $data = $db->getValue('SELECT message FROM '.BookPostsContent::table().' WHERE pid = '.$pid);

    $insert = array(
        'uid' => intval($row['uid']),
        'bookid' => intval($row['bookid']),
        'loginip' => $row['loginip'],
        'createdate' => $row['createdate'],
        'date' => $row['date'],
        'digest' => intval($row['digest']),
        'remarks' => $row['remarks'],
        'deleted' => intval($row['deleted']),
        'applydigest' => intval($row['applydigest']),
        'isadvance' => intval($row['isadvance']),
        'lastpost' => $row['lastpost'],
        'content' => $data,
    );

    $collect->insert($insert);
}