<?php
/**
 * 10W字以上的原创作品自动开通打赏功能
 * 1 5 * * * 
 */
require_once dirname(dirname(dirname(__FILE__))) . '/init.php';

$size = 100000;
$books = $db->select(array('bookid'))->from(Book::table())->where('type = 2 AND tipping = 0 AND size >= ' . $size)->find();
if (empty($books))
{
    exit();
}

foreach ($books as $book)
{
    $bookId = $book['bookid'];
    $db->update(Book::table())->value(array('tipping' => 1))->where('bookid = '.$bookId)->q();
    updateBookInfo($bookId);
}