1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- class Token_model extends CI_Model{
- private $collection_name = 'token';
- public function __construct()
- {
- parent::__construct();
- }
- private $model = array(
- "token" =>"",
- "expires_time" => ""
- );
- public function get_model(){
- return $this->model;
- }
- public function find_token($token,$time)
- {
- $this->clear_token($time);
- $token_info = $this->mongo_db->where("token", $token)->where_gt("expires_time", $time)->find_one($this->collection_name);
- return $token_info;
- }
- public function clear_token($time){
- return $this->mongo_db->where_lt("expires_time", $time)->delete_all($this->collection_name);
- }
- public function save_token($token){
- return $this->mongo_db->insert($this->collection_name,$token);
- }
- public function delete_token($token){
- return $this->mongo_db->where("token",$token)->delete($this->collection_name);
- }
- }
|