Closed tbowmo closed 6 years ago
Am I correct, that compound primary keys are not supported?
I have a table like:
CREATE TABLEanswer( nerdIdint(11) NOT NULL, invitationIdint(11) NOT NULL, attendingtinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (nerdId,invitationId), KEYto(invitationId), CONSTRAINTfromFOREIGN KEY (nerdId) REFERENCESnerd(id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINTtoFOREIGN KEY (invitationId) REFERENCESinvitation(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE
(
int(11) NOT NULL,
tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (
,
), KEY
), CONSTRAINT
FOREIGN KEY (
) REFERENCES
) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT
) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
and trying to query with: $answer = ORM::for_table('answer')->find_one(Array('nedId' => 2, 'invitationId' => 1);
gives me the following error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
I then switched to use raw_query(), which retrieved the record.. But when saving, I get an error with primary key ID missing..
Should have read the documentation better..
Reading this, helped me solve the issue https://idiorm.readthedocs.io/en/latest/configuration.html#id-column
Am I correct, that compound primary keys are not supported?
I have a table like:
CREATE TABLE
answer(
nerdIdint(11) NOT NULL,
invitationIdint(11) NOT NULL,
attendingtinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (
nerdId,
invitationId), KEY
to(
invitationId), CONSTRAINT
fromFOREIGN KEY (
nerdId) REFERENCES
nerd(
id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT
toFOREIGN KEY (
invitationId) REFERENCES
invitation(
id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
and trying to query with: $answer = ORM::for_table('answer')->find_one(Array('nedId' => 2, 'invitationId' => 1);
gives me the following error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
I then switched to use raw_query(), which retrieved the record.. But when saving, I get an error with primary key ID missing..