using cakephp on email column in the db i have unique constraint, how can check before inserting record开发者_高级运维ing that email may be duplicate or after inserting detect and print error.
Check out the Core Validation Rules. There's one for isUnique
.
Found another good example at http://www.davidtan.org/cakephp-tutorial-how-to-insert-records-into-table-with-unique-index-made-up-of-2-or-more-fields/
精彩评论