title: PDO Update Multiple Rows
body: <p>Bit of a noob when it comes to PDO. We have a a table that needs to be updated with a  cron job daily. The idea is to query the table and for each "active = 1" get an integer from a duration column convert that into days, get the "expiration" column and the duration to the expiration and update the expiration. </p>
  
  <p>I am not even close to getting this to work, I am trying to just get the basics for now. Return the duration which is in hours divide by 24 add that to the date column as days and update EACH row with the appropriate new time. </p>
  
  <p>The problem is I do not know how to update each row with its own information. I have the code below, it updates each row but the new "expires" date ends up being the same even though the expires values are different.</p>
  
  <pre><code>static function cronSetFeatured(){
  
      try{
          $db = new PDO('mysql:host=127.0.0.1;dbname=mydb', 'dbuser', 'pw' );
          $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      }catch(PDOException $e){
          echo $e-&gt;getMessage();
          die();
      }
  
      $query = $db-&gt;query('SELECT * FROM featured_producers ');         
      $now =  date('Y-m-d H:i:s');
      while($r = $query-&gt;fetch(PDO::FETCH_OBJ)){      
              $duration = $r-&gt;duration;
              $ddays = $duration / 24;
              $date = $r-&gt;date;
              $expires = date("Y-m-d", strtotime($date. " + ".$ddays." days"));   
          }
      $sql = "UPDATE `featured_producers` 
                      SET `expires`= ?
                      WHERE `id` != 0";
  
              $q = $db-&gt;prepare($sql);
  
              $q-&gt;execute(array($expires));
              echo $expires.'&lt;br&gt;';
  
  }
  </code></pre>