j4mie / paris

A lightweight Active Record implementation for PHP5, built on top of Idiorm.
http://j4mie.github.com/idiormandparis/
996 stars 131 forks source link

Composite Key association #15

Closed qasimshabbir closed 13 years ago

qasimshabbir commented 13 years ago

I have table which has composite primary key. How would I associate this table by using has_one function.

for e.g I have a product and product_description table. product_description contains multiple description with language information. But it create one-to-one association with product. product_description has product_id and language_id as composite primary key.

j4mie commented 13 years ago

Hi,

Unfortunately, Paris and Idiorm don't currently have support for composite keys. You may be able to build the association by adding a method to your model which runs a query to select the related rows manually, but you probably won't be able to save any data in the related rows easily.

Hope this helps - you may need to use a more full-featured database library if you need support for more complex associations.

Jamie

qasimshabbir commented 13 years ago

Hi,

Thanks for your quick reply.

I really like your idea will use in some small projects. Thanks again for great work.

Regards -Q

On Sun, Mar 20, 2011 at 3:34 PM, j4mie < reply@reply.github.com>wrote:

Hi,

Unfortunately, Paris and Idiorm don't currently have support for composite keys. You may be able to build the association by adding a method to your model which runs a query to select the related rows manually, but you probably won't be able to save any data in the related rows easily.

Hope this helps - you may need to use a more full-featured database library if you need support for more complex associations.

Jamie

Reply to this email directly or view it on GitHub: https://github.com/j4mie/paris/issues/15#comment_894874