3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1240 Views |
-
Unique Key on 2 Cols

28 May 2010 at 12:50am Last edited: 28 May 2010 12:52am
Hi,
what is the right syntax to add a 2-col unique index ?
I'd like to have a unique index on Field_1 AND Field_2static $indexes = array(
"Uniques" => ????,
);in SQL would be:
...
UNIQUE KEY `myUniqueIndex` (`FIELD_1`,`FIELD_2`),
... -
Re: Unique Key on 2 Cols

10 June 2010 at 2:24am Last edited: 10 June 2010 2:24am
no idea ?
(sry for bump)
-
Re: Unique Key on 2 Cols

11 June 2010 at 12:00pm Last edited: 11 June 2010 12:05pm
Hi.
You should be able to do this:
<code php>
static $indexes = array(
"Uniques" => array(
"type" => "unique",
"value" => "`FIELD_1`,`FIELD_2`"
)
);
</code>Another variation is:
<code php>
static $indexes = array(
"Uniques" => "(`FIELD_1`,`FIELD_2`)",
);
</code>But this doesn't create a unique index, just a two-column index called Uniques.
Mark
| 1240 Views | ||
|
Page:
1
|
Go to Top |


