Search code examples
insertduplicatesadodbconcrete5

Concrete 5 ADODB update and insert duplicate primary key


I'm creating a new package for Concrete 5 (5.4.0+). Inserting a new block works perfectly. But when I edit an existing block, it tries to INSERT again when I click 'save', instead of UPDATE.

The two fields on the database that affect this are bID and eID. Both are non-auto-incrementing INT(10) default none NOT NULL.

The values are passed in an associative array $args in the controller and I'm calling the parent save method with Parent::save($args);

Any help/input would be appreciated. PS: I have looked over this on the net and the C5 forums did turn up some stuff which I tried, mostly relating to the database fields, but I still get the above error. I don't want to overwrite the ADODB save() method if possible.

--- EDIT ---

Perhaps I'm looking at this all wrong. Let me say what I'm trying to achieve. I need the eID to remain 37 (for example) across multiple edits of the block. The bID can increment away AFAIC.

How do I get the eID to remain 37 on edit, but increment by 1 on creation of a new instance? Make sense?

A second table references the eID field, and edited instances of an entry on this table must have the same eID unless a new instance is created. Sry - clear as mud I know.


Solution

  • So I looked into the existing packages to duplicate this funcitonality and my question has evolved into this: PHP Concrete 5 Pass Variables to Add.php

    Follow the rabbit ;)