Composite primary key

4 messages Options
Embed this post
Permalink
.-2

Composite primary key

Reply Threaded More More options
Print post
Permalink
Hi
 
I have a table with composite primary keys. The primary key consists of 2 columns. How would I do a row insert?
 
Thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

.-2

Re: Composite primary key

Reply Threaded More More options
Print post
Permalink
If cake does not support composite keys, how would I create a custom query to do this?
 
Thanks!

On Sat, Aug 23, 2008 at 3:41 AM, . <[hidden email]> wrote:
Hi
 
I have a table with composite primary keys. The primary key consists of 2 columns. How would I do a row insert?
 
Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

irfani YangBaikHati

Re: Composite primary key

Reply Threaded More More options
Print post
Permalink
you can add one field eg (ID auto increment) as the primary key, and the 2 columns become a usual field.

On Sat, Aug 23, 2008 at 6:42 PM, . <[hidden email]> wrote:
If cake does not support composite keys, how would I create a custom query to do this?
 
Thanks!

On Sat, Aug 23, 2008 at 3:41 AM, . <[hidden email]> wrote:
Hi
 
I have a table with composite primary keys. The primary key consists of 2 columns. How would I do a row insert?
 
Thanks






--
irfani

http://irfani.web.id
Y! irfani_s

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

James K

Re: Composite primary key

Reply Threaded More More options
Print post
Permalink
In reply to this post by .-2

Cake does not support composite primary keys, but a work around would
be to add a single primary key field (id), and then set a unique
constraint on your composite key fields. Same effect, and works with
cake.

If you want to do a custom query, just do $this->modelName-
>query('INSERT INTO MyTable...');

On Aug 23, 6:41 am, . <[hidden email]> wrote:
> Hi
>
> I have a table with composite primary keys. The primary key consists of 2
> columns. How would I do a row insert?
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---