Advertisement
aleksv11

Untitled

May 31st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1.    
  2. /*
  3.  
  4. $check = $this->check_before_send();
  5.  
  6. if ($check) {
  7. //  что-то делаем
  8. }
  9.  
  10. */
  11.  
  12.  
  13.  public function check_before_send() {
  14.  
  15.         $sql = "SELECT * FROM signals_before_send WHERE symbol =  '" . $this->symbol . "' AND signal_from = '" . $this->signal_from . "' AND time_insert < '" . time() - (int)20 . "'";
  16.  
  17.         $check_result = $this->db->query($sql);
  18.  
  19.         if ($check_result->num_rows > 0) {
  20.              
  21.             return false;
  22.  
  23.         } else {
  24.            
  25.             $sql = "INSERT INTO `signals_before_send`(
  26.               `symbol`,
  27.               `signal_from`,
  28.               `time_insert`
  29.             ) VALUES('" .
  30.               implode("','", [
  31.                 $this->symbol,
  32.                 $this->signal_from,
  33.                 time()
  34.               ])
  35.             . "')";
  36.  
  37.             $this->db->query($sql);
  38.             return true;
  39.         }
  40.  
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement