Perfect, thanks for that. On Apr 21, 7:08 pm, Andy Dirnberger <andy.dirnber...@gmail.com> wrote: > Here's a stripped down example of how I do it: > > app_model.php > class AppModel extends Model { > > ... > > function isUniqueMulti($data, $fields) { > if (!is_array($fields)) { > $fields = array($fields); > } > > foreach ($fields as $key) { > $tmp[$key] = $this->data[$this->name][$key]; > } > > return $this->isUnique($tmp, FALSE); > } > > } > > some_model.php > class SomeModel extends AppModel { > var $validate = array( > 'field1' => array( > 'rule' => array('isUniqueMulti', array('field1', 'field2')), > 'required' => TRUE, > 'message' => 'Error Message', > ), > 'field2' => array( > 'rule' => 'notEmpty', > 'required' => TRUE, > 'message' => 'Error Message', > ), > ); > > } > > On Apr 21, 8:40 am, Swanny <stuarts...@gmail.com> wrote: > > > > > > > Is there a way in a model to verify that a record does not exist > > already that matches a certain criteria. In the database table are > > three columns: id, list_id and product_id. I would like to be able to > > tell if there already exists a record with the same list_id AND > > product_id as the one being added using the form which would then > > produce an error as this would be a duplicate. > > > Example: I try to add a product with product_id 23 and list_id 12 but > > the table already contains a record with this information. > > > Thanks > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en