<?php
class SyncAction extends BaseAction
{
    public function run()
    {
        $bookid = trim(Yii::app()->request->getPost('bookid'));
        $spider = trim(Yii::app()->request->getPost('spider'));
        $count = trim(Yii::app()->request->getPost('count'));
        $listurl = trim(Yii::app()->request->getPost('listurl'));
        $detialurl = trim(Yii::app()->request->getPost('detialurl'));
        
        $collect = Collects::model()->find('bookid=:bookid',array(':bookid'=>$bookid));
        if (empty($collect))
        {
            echo '采集记录不存在，无法完成对应';
            Yii::app()->end();
        }
        $collect->spider = $spider;
        $collect->count = $count;
        $collect->listurl = $listurl;
        $collect->detialurl = $detialurl;
        $collect->save();
        
        if ($collect->hasErrors())
        {
            print_r($collect->getErrors());
        }
        else
        {
            echo '对应成功';
        }
        Front::updateBooksFile($bookid);
        Yii::app()->end();
    }
}