Model_check.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Model_check extends Lin_Model
  3. {
  4. function __construct(){
  5. parent::__construct();
  6. $this->load->database();
  7. $this->table = 'check';
  8. $this->load_table('check');
  9. }
  10. public function checkOverdue($check_name,$number,$check_address){
  11. $check_name = trim($check_name);
  12. $check_address = trim($check_address);
  13. if(empty($check_name) || empty($check_address)){
  14. return false;
  15. }
  16. $info = $this->find("(check_name = '".$check_name."') or (check_address like '%".$check_address."%')","*",'addtime DESC');
  17. if(empty($info)){
  18. }else{
  19. if((time() - $info['addtime'] ) < $info['zx_hours']*60*60 ){
  20. if($info['number'] == $number){
  21. return true;
  22. }
  23. return false;
  24. }
  25. }
  26. $this->insert([
  27. 'check_address' => $check_address,
  28. 'check_name' => $check_name,
  29. 'number' => $number,
  30. 'addtime' => time(),
  31. 'zx_hours'=> 72
  32. ]);
  33. return true;
  34. }
  35. public function checkOverduetest($check_name,$number,$check_address){
  36. $check_name = trim($check_name);
  37. $check_address = trim($check_address);
  38. if(empty($check_name) || empty($check_address)){
  39. return false;
  40. }
  41. $info = $this->find("(check_name = '".$check_name."') or (check_address like '%".$check_address."%')","*",'addtime DESC');
  42. echo "<pre>";
  43. var_dump($check_name);
  44. var_dump($check_address);
  45. var_dump($info);
  46. if(empty($info)){
  47. }else{
  48. var_dump(time());
  49. var_dump($info['addtime']);
  50. var_dump($info['zx_hours']*60*60);
  51. var_dump((time() - $info['addtime'] ));
  52. if((time() - $info['addtime'] ) < $info['zx_hours']*60*60 ){
  53. if($info['number'] == $number){
  54. return true;
  55. }
  56. return false;
  57. }
  58. }
  59. return true;
  60. $this->insert([
  61. 'check_address' => $check_address,
  62. 'check_name' => $check_name,
  63. 'number' => $number,
  64. 'addtime' => time(),
  65. 'zx_hours'=> 72
  66. ]);
  67. return true;
  68. }
  69. } //end class