/** * Load country * * @param integer|string $id */ public function __construct($id = null) { parent::__construct(); if ($id !== null) { $this->load(DB::select()->where(is_numeric($id) ? 'id' : 'code', '=', $id)); } }
/** * Load token * * @param integer|string $id */ public function __construct($id = null) { parent::__construct(); if ($id !== null) { $this->load(DB::select()->where(is_numeric($id) ? 'id' : 'token', '=', $id)); // Expired token? if ($this->loaded() && $this->expires < time()) { $this->delete(); } } // Garbace collection if (mt_rand(1, 100) === 1) { self::gc(); } }