| 6 database.mysql-common.inc | db_add_index(&$ret, $table, $name, $fields) |
| 6 database.pgsql.inc | db_add_index(& |
| 7 database.inc | db_add_index($table, $name, $fields) |
| 8 database.inc | db_add_index($table, $name, $fields) |
Add an index.
Parameters
$ret: Array to which query results will be added.
$table: The table to be altered.
$name: The name of the index.
$fields: An array of field names.
Related topics
20 calls to db_add_index()
File
- includes/
database.mysql-common.inc, line 441 - Functions shared between mysql and mysqli database engines.
Code
function db_add_index(&$ret, $table, $name, $fields) {
$query = 'ALTER TABLE {' . $table . '} ADD INDEX ' . $name . ' (' . _db_create_key_sql($fields) . ')';
$ret[] = update_sql($query);
}
Login or register to post comments
Comments
Simple index example
Here's a very simple example to show how to add an index to a column on the profile_values table. It's important to note that even if your index includes only one field, you need to use an array here.
<?phpdb_add_index(
$ret,
'profile_values',
'uid',
array('uid')
);
?>