title: cakephp isUnique for 2 fields?
body: <p>I have a registration form in which users can fill in two email address (email1 &amp; email2). Marketing's requirement is that they need to be unique (unique as in if we had 10 users, then there would be 10*2=20 unique email address). </p>
  
  <p>The system is already built on cakephp, so what I'd like to know is, is there something similar to the isUnique feature (unique in one field) that can do this right out of the box? Or am I doomed to code this myself? Thanks in advance.</p>
  
  <p>EDIT: built on Richard's example, this worked for me:</p>
  
  <pre><code>function checkUnique($data, $fields) {
      if (!is_array($fields)) {
          $fields = array($fields);
      }
      foreach($data as $key) {
          $checks = $key;
      }
      if (empty($checks)) {
        return true;  //allow null
      }
      foreach($fields as $key) {
          $tmp[$key] = $checks;
      }
      if (isset($this-&gt;data[$this-&gt;name][$this-&gt;primaryKey])) {
          $tmp[$this-&gt;primaryKey] = "&lt;&gt;".$this-&gt;data[$this-&gt;name][$this-&gt;primaryKey];
      }
      return $this-&gt;isUnique($tmp);
  }
  </code></pre>