I have a table that uses an auto-incremented primary key and it has several fields.
<column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true" />
<column name="field1" type="INTEGER" required="true" />
<column name="field2" type="INTEGER" required="true" />
<column name="field3" type="INTEGER" />
<column name="field4" type="INTEGER" />
<column name="field5" type="INTEGER" />
I want to make sure that a field1
+ field2
combo isn't used more than once, so I added them as primary keys in addition to the id, but this is creating problems when I try to use findPK()
. I would prefer to have an auto-incremented id as primary key but I also want to make sure that the combo field1
+ field2
isn't entered more than once.
<column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true" />
<column name="field1" type="INTEGER" required="true" primaryKey="true" />
<column name="field2" type="INTEGER" required="true" primaryKey="true" />
Try setting an unique index on those fields, something like :
<unique>
<unique-column name="/field1/" />
<unique-column name="/field2/" />
</unique>
as per propel doc