<?php
class ChangeViewAction extends BaseAction
{
    public function run()
    {
        $id = Yii::app()->request->getQuery('id');
        $book = Books::model()->findByPk($id);
        if ($book->view)
        {
            $text = '<font color=red>隐藏</font>';
            $book->view = 0;
        }
        else
        {
            $text = '显示';
            $book->view = 1;
        }
        $book->save();
        
        echo CHtml::link($text, '', array('onclick' => 'changeView('.$id.',this);'));
        Yii::app()->end();
    }
}