Ejemplo n.º 1
0
 /**
  * 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));
     }
 }
Ejemplo n.º 2
0
Archivo: token.php Proyecto: anqh/core
 /**
  * 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();
     }
 }