Personally, I'd make those DEFAULT NULL, not the empty string.
Actually, I'd make most of them NOT NULL.
On Sun, Apr 20, 2008 at 12:02 PM, Joshua McFarren <[EMAIL PROTECTED]> wrote:
>
> Cake's validation will respect your DB.
>
> CREATE TABLE `users` (
> `id` int(11) unsigned NOT NULL auto_increment,
> `username` varchar(255) NOT NULL default '',
> `password` varchar(255) NOT NULL default '',
> `email` varchar(255) NOT NULL default '',
> `profile` varchar(255) NOT NULL default '',
> `created` datetime default NULL,
> `modified` datetime default NULL,
> PRIMARY KEY (`id`),
> UNIQUE KEY `username` (`username`),
> UNIQUE KEY `profile ` (`profile`)
> ) ENGINE=MyISAM
>
>
>
> On Apr 20, 11:21 am, Chez17 <[EMAIL PROTECTED]> wrote:
> > I am having issues making sure that a field is unique. I am beginner
> > so please go easy on me. Right now, I am trying to create a simple
> > login system where the user name name and profile name have to be
> > unique. I have been cutting and pasting some stuff together and I
> > can't seem to get this to work out. Here is a sample of my 'create'
> > view:
> >
> > <label for="profile">Profile Name:</label>
> > <?php echo $html->password('User/profile', array('size' => 20)); ?>
> > <?php echo $html->tagErrorMsg('User/profile', 'You need to enter a
> > profile name.') ?>
> >
> > Now, here is my validation function:
> >
> > var $validate = array(
> > 'username' => VALID_NOT_EMPTY,
> > 'password' => VALID_NOT_EMPTY,
> > 'profile' => VALID_NOT_EMPTY
> > );
> > When I tried use custom rules and try to make the validate array check
> > for uniqueness, my message gets lost. It will keep displaying the
> > 'You need to enter a profile name' error message, not the one I
> > specify in the validate array. So now I am trying to do some custom
> > validation, but I don't understand the find() function. I couldn't
> > find one concrete example of how to use it. I am too much of a
> > beginner to understand the API that they put out.
> >
> > I would like to know how to solve my problem both ways. How can I get
> > the message from the validate function to my view? Also, how can I
> > write a custom find() statement so I can check if a profile name is
> > already in the database?
> >
> > Thanks for your time,
> > Dave
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---