title: Update Magento database table with a WHERE clause
body: <p>I have a table called 'sample' with fields as 'sample_id, 'order_id', order_email_id', 'review_request', 'coupon_sent'.</p>
  
  <pre><code>$to_date = date('Y-m-d H:i:s',strtotime('-1 days'));
          $orders = Mage::getModel('sales/order')-&gt;getCollection()-&gt;addFieldToFilter('status', 'complete')-&gt;addFieldToFilter('updated_at',array('to' =&gt; $to_date ))-&gt;addAttributeToSelect('customer_email')-&gt;addAttributeToSelect('entity_id');
          foreach ($orders as $order) 
          {
              $email = $order-&gt;getCustomerEmail();
              $id = $order-&gt;getEntityId();
              //echo 'Email: ' . $email . ' Id: ' .$id .'&lt;br/&gt;' ;     
              $sample = Mage::getModel('sample/sample');
              $sample-&gt;setOrderId($id);
              $sample-&gt;setOrderEmailId($email);
              $sample-&gt;save();
              echo '&lt;br/&gt;Record Added';
  
          }
  
          $posts = Mage::getModel('sample/sample')-&gt;getCollection();
          foreach($posts as $sample_post)
          {
              if($sample_post-&gt;getReviewRequest()==0)
              {
                       code to send email to email id's from this table's order_email_id field
                      try
                      {
                         (if($mail-&gt;send() == true)
             { 
              echo "&lt;br&gt; Mail Sent ";
                         //**WHERE clause condition to update 'review_request' field for all successful emails sent**
  
                        }
                        else {echo 'Mail not Sent';}
                     }
                     catch(Exception e) {}
  </code></pre>
  
  <p>So acc to my code how do I put the WHERE clause which sets review_request = 1 for all the records where the emails have been sent successfully.</p>
  
  <p>Thanks in advance</p>