Thursday, May 30, 2013

User defined id

Hi there,

I'm just starting a new project with Cakephp but I'm stuck with a very basic problem.

I have a "countries" table that looks like this:

CREATE TABLE `countries` (
 `id` varchar(7) NOT NULL DEFAULT '',
 `name` varchar(255) NOT NULL DEFAULT '',
 `description` varchar(255) NOT NULL DEFAULT '',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


As you can see want to use a VARCHAR as primary key as I want to use a customized country code as primary key (e.g. FR-2013, DE-2010, ES-2010 etc), I also want users to be able to manually insert this code. I know using a non-numeric id is not recommended but I have my reasons.

Now, when I create a form to add data (I want users to be able to add new countries), the `id` field is automatically hidden, I could probably come up with a workaround but I was wondering if there a "proper" way to do it.

I also have other tables where I have a similar situation.

Thanks,
Eros

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: