Token_model.php 971 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class Token_model extends CI_Model{
  3. private $collection_name = 'token';
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. }
  8. private $model = array(
  9. "token" =>"",
  10. "expires_time" => ""
  11. );
  12. public function get_model(){
  13. return $this->model;
  14. }
  15. public function find_token($token,$time)
  16. {
  17. $this->clear_token($time);
  18. $token_info = $this->mongo_db->where("token", $token)->where_gt("expires_time", $time)->find_one($this->collection_name);
  19. return $token_info;
  20. }
  21. public function clear_token($time){
  22. return $this->mongo_db->where_lt("expires_time", $time)->delete_all($this->collection_name);
  23. }
  24. public function save_token($token){
  25. return $this->mongo_db->insert($this->collection_name,$token);
  26. }
  27. public function delete_token($token){
  28. return $this->mongo_db->where("token",$token)->delete($this->collection_name);
  29. }
  30. }