<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class BookCreditsLog extends Model
{
	public static function single($className = __CLASS__)
	{
		if (is_null(self::$_self[$className]))
		{
			self::$_self[$className] = new $className;
		}
		
		return self::$_self[$className];
	}
	
    public static function table()
    {
        return 'ig_bookcreditslog';
    }
    
    public function todayForumCredits($bookId, $date = CDATE)
    {
        return $this->Db()->getValue('SELECT SUM(credit) FROM '.self::table().' WHERE bid='.S::sqlEscape($bookId).' AND `date`='.S::sqlEscape($date));
    }
}