title: Using MySQL user variables through multiple statements in PDOStatement
body: <p>I was wondering if you can set a user variable in mysql in a PDOstatement and then use it in a query in the same statement? I have the impression that if I use separate statements the user variable is 'lost' though I am not certain. Is each PDOStatement->execute a different transaction? And if yes if use a transaction through PDO will the user variable set in one statement can be used in one following it?</p>
  
  <p>Basically I am trying to write a php script that takes as an argument a date and time and searches through a table for rows that match that date and time and the following 5 hours but I was thinking of doing the date/time arithmetic operations in mysql since it has so many than trying to make my own in php which frankly sounds a lot of work; I would have to check for when is midnight(00:00) when the day changes, the month....</p>
  
  <p>I am trying to familiarize myself in php scripting for a website using a database....</p>