TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
About Multi primary keys / foreign keys in ORM Issue
  • There it is


    I'm really need this feauture.

    So, i have two tables block's and composites. And table Composites_Blocks with columns id_block, id_composite. I want work with relations using ORM::add() method. It's ok.

    But then i want store some data in Composites_Blocks rows, like coords of block in this composite and i have columsn in Composites_Blocks - "x" and "y". When i want create or remove relation in Composites_Blocks i use ORM:: add() and ORM::remove() methods. When i need update data in Composites_Blocks i'm use ORM::factory("Composites_Blocks");


    And what i need write in $_primary_key when i have multy keys as one key (id_block and id_composite) ??? If $_primary_key empty then i have "not loaded" error when try update.

    If i write just id_block or id_composite when i want update data in foreach this code work wrong.

    $relation = ORM::factory("orm_tanksblocks") ->where("id_composite", "=", $id_composite) ->and_where("id_block", "=", $orm_block->id_block) ->find();


    If i have two rows in Composites_Blocks with same id_composite It updates both rows or nothing.

    And now i need add ID column in Composites_Blocks and use this ID as $_primary_key and now it work fine.

    But why i need ID column?? It's not usefull for me and just leak memory in DB. This is wrong. Please, i need Multi primary keys in ORM.

  • Like the issue says, patches welcome. Composite keys are complicated to support, and very few people need it.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion