V6 Provider: \ADOdb\database\drivers\[driver]\ADOMetaFunctions
====== metaIndexes ======
~~NOTOC~~
== See Also ==
[[v6:dictionary:metaprimarykeys|metaPrimaryKeys()]]\\
== Syntax ==
mixed metaIndexes(
string $tableName,
optional bool $includePrimary=false,
optional string $owner=false,
)
===== Description =====
The function ''metaIndexes()'' returns a list of indexes associated with a specific table. If there are no indexes defined for the requested table, the method returns false.
Version 6 of ADOdb provides 2 different responses based on the setting ''**suppressExtendedMetaIndexes**'' in the ''**connectionDefinitions**'' class. If the value is set to **true**, then all drivers return the same array of data. There are no database-specific entries. The array of data is as followed:
----------------------------------------------
[index_name] => Array
(
[unique] => 0
[primary] => 0
[columns] => Array
(
[0] => Column 1
[1] => Column 2
[2] => etc........
)
)
-------
If the value is set to **false**, then the response is as follows:
[index_name] => Array
(
[unique] => 0
[primary] => 0
[columns] => Array
(
[0] => Column 1
[1] => Column 2
[2] => etc........
)
[index-attributes]
(
[key] => value
[key] => etc.....
)
[column-attributes]
(
[col1] => (
[key] => value
[key] => etc....
)
[col2] => etc...
)
)
The index attributes are the database specific attributes associated with the index as a whole. The column attributes are the **index** attributes of specific columns. Here is an example item from the MySQL employees table
Array
(
[PRIMARY] => Array
(
[unique] => 1
[primary] => 0
[columns] => Array
(
[0] => emp_no
)
[index-attributes] => Array
(
[table] => employees
[non_unique] => 0
[key_name] => PRIMARY
[cardinality] => 285156
[packed] =>
[index_type] => BTREE
[index_comment] =>
[visible] => YES
[expression] =>
)
[column-attributes] => Array
(
[emp_no] => Array
(
[seq_in_index] => 1
[column_name] => emp_no
[collation] => A
[sub_part] =>
[null] =>
)
)
)
)
The casing of metaIndexes is returned in the native mode for the database, you should not assume the casing for the returned data.
===== Optional Parameters =====
==== $includePrimary ====
If set, the index associated with the primary key is also returned
==== $owner ====
If specified, only returns indexes associated with a table owned by that name. Support for this function is limited, see the [[v6:database:feature_comparison]].
===== Usage =====
/*
* Database connection to DB2 database sample assumed
*/
$mi = $db->metaIndexes('ACT');
print_r($mi);
/*
* Returns
Array
(
[PK_ACT] => Array
(
[unique] => 0
[columns] => Array
(
[0] => ACTNO
)
)
[XACT2] => Array
(
[unique] => 0
[columns] => Array
(
[0] => ACTNO
[1] => ACTKWD
)
)
)
*/