MDB & multiple column indexes
| From: | Justin Koivisto | Date: | Fri, 01 Jul 2005 15:58:32 +0000 |
| Subject: | MDB & multiple column indexes | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19850@lists.php.net to get a copy of this message | ||
In the midst of creating a dynamic table, I need to be able to create a
unique index using two fields. To better illustrate what I need to do,
this is how I do it from the mysql command line:
ALTER TABLE table_name ADD PRIMARY KEY (field_one, field_two);
I realize that MDB doesn't support primary keys, so the next approach
would be:
ALTER TABLE table_name ADD UNIQUE key_name (field_one, field_two);
The best I have gotten is like this:
$idx=array(
'FIELDS'=>array(
'field_one'=>array(),
'field_two'=>array()
)
);
$result=$mdb->createIndex($table_name,$key_name,$idx);
Which results in the same as:
ALTER TABLE table_name ADD INDEX key_name (field_one, field_two) ;
If I use the following (or any variation of), I get the same results:
$idx=array(
'FIELDS'=>array(
'field_one'=>array('unique'=>TRUE),
'field_two'=>array('unique'=>TRUE)
)
);
$result=$mdb->createIndex($table_name,$key_name,$idx);
Can MDB do what I am trying to accomplish? If so, what am I missing?
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com