function dba_get_primary_key in Database Administration 5
1 call to dba_get_primary_key()
File
- ./
dba.module, line 719 - Allows administrators direct access to their Drupal database. Written by Jeremy Andrews <jeremy@kerneltrap.org>, June 2004. PostgreSQL functionality provided by AAM <aam@ugpl.de> Major security audit, porting, and maintenance by Derek…
Code
function dba_get_primary_key($table) {
if (_is_mysql()) {
$rows = array();
$tables = dba_get_active_tables();
$quantity = count($tables);
if ($quantity == 1) {
$result = dba_describe_table($table, FALSE);
while ($row = db_fetch_array($result)) {
if ($row['Key'] == "PRI") {
return $row['Field'];
}
}
}
else {
drupal_set_message(t('Unable to return the primary key for more than one table at a time.'), 'error');
}
}
else {
// Not MySQL, so currently unsupported.
return;
}
return;
}