// +---------------------------------------------------------------------- namespace app\common\dao\community; use app\common\dao\BaseDao; use app\common\model\community\CommunityTopic; class CommunityTopicDao extends BaseDao { protected function getModel(): string { return CommunityTopic::class; } public function countInc(int $id, string $filed, int $inc = 1) { return $this->getModel()::getDb()->where($this->getPk(), $id)->inc($filed, $inc)->update(); } public function countDec(int $id, string $filed, int $dec = 1) { try{ return $this->getModel()::getDb()->where($this->getPk(), $id)->dec($filed, $dec)->update(); }catch (\Exception $exception) { } } }