title: Determine if SQL UPDATE changed value of column
body: <p>I have a table with a text column called myTextColumn.  I would like to do something in the PHP application only if an UPDATE changed the value.  I am not using triggers.  Is there a better way to do so other than the following?  Thank you</p>
  
  <pre><code>function updateTable($data)
  {
      $sql='SELECT id FROM myTable WHERE id=:id AND myTextColumn!=:myTextColumn';
      $stmt=db::db()-&gt;prepare($sql);
      $stmt-&gt;execute($data);
      if($stmt-&gt;fetchColumn()) {
          $sql='UPDATE myTable SET myTextColumn=? WHERE id=?';
          $stmt=db::db()-&gt;prepare($sql);
          $stmt-&gt;execute($data);
          return true;
      }
      else {return false;}
  }
  
  if(updateTable(array('id'=&gt;123, 'myTextColumn'=&gt;'Some text goes here')))
  {
      echo('It Changed');
  }
  </code></pre>