SHARE
TWEET

Untitled

a guest Jun 17th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT h.ID, h.SUB_ID
  2. FROM history h
  3. WHERE 1=1
  4. AND h.SUB_ID = :subId
  5.                     AND (
  6.                         1=1
  7.                         AND (
  8.                             TO_DATE(:startDate, 'YYYY-MM-DD HH24:MI:SS') >= h.VALIDFROM
  9.                             AND TO_DATE(:startDate, 'YYYY-MM-DD HH24:MI:SS') <= NVL(h.VALIDUNTIL,sysdate)
  10.                         ) OR (
  11.                             TO_DATE(:startDate, 'YYYY-MM-DD HH24:MI:SS') <= h.VALIDFROM
  12.                             AND TO_DATE(:endDate, 'YYYY-MM-DD HH24:MI:SS') >= NVL(h.VALIDUNTIL,sysdate)
  13.                         ) OR (
  14.                             TO_DATE(:endDate, 'YYYY-MM-DD HH24:MI:SS') >= h.VALIDFROM
  15.                             AND TO_DATE(:endDate, 'YYYY-MM-DD HH24:MI:SS') <= NVL(h.VALIDUNTIL,sysdate)
  16.                         )
  17.                     )
  18.      
  19. $query = $this->db->prepare($query);
  20. $query->bindValue('subId', 20180101123456789, PDO::PARAM_STR);
  21. $query->bindValue('startDate', $validFrom->format('Y-m-d H:i:s'), PDO::PARAM_STR);
  22. $query->bindValue('endDate', $validUntil->format('Y-m-d H:i:s'), PDO::PARAM_STR);
  23. $query->execute();
  24. $result = $query->fetchAll();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top