| @@ 462-475 (lines=14) @@ | ||
| 459 | * @param boolean $is_unique |
|
| 460 | * @return void |
|
| 461 | */ |
|
| 462 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
|
| 463 | { |
|
| 464 | if($this->isIndexExists($table_name, $index_name)) |
|
| 465 | { |
|
| 466 | return; |
|
| 467 | } |
|
| 468 | if(!is_array($target_columns)) |
|
| 469 | { |
|
| 470 | $target_columns = array($target_columns); |
|
| 471 | } |
|
| 472 | ||
| 473 | $query = sprintf("create %s index %s on %s%s (%s)", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, implode(',', $target_columns)); |
|
| 474 | $this->_query($query); |
|
| 475 | } |
|
| 476 | ||
| 477 | /** |
|
| 478 | * Drop an index from the table |
|
| @@ 383-392 (lines=10) @@ | ||
| 380 | * @param boolean $is_unique |
|
| 381 | * @return void |
|
| 382 | */ |
|
| 383 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
|
| 384 | { |
|
| 385 | if(!is_array($target_columns)) |
|
| 386 | { |
|
| 387 | $target_columns = array($target_columns); |
|
| 388 | } |
|
| 389 | ||
| 390 | $query = sprintf("alter table `%s%s` add %s index `%s` (%s);", $this->prefix, $table_name, $is_unique ? 'unique' : '', $index_name, implode(',', $target_columns)); |
|
| 391 | $this->_query($query); |
|
| 392 | } |
|
| 393 | ||
| 394 | /** |
|
| 395 | * Drop an index from the table |
|