protected function getConstraintKeys($schemaName, $tableName)
{
$table = $schemaName === null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`";
$sql = "SHOW INDEX FROM {$table}";
$command = $this->getDbConnection()->createCommand($sql);
$primary = array();
foreach ($command->query() as $row) {
if ($row['Key_name'] === 'PRIMARY') {
$primary[] = $row['Column_name'];
}
}
// MySQL version was increased to >=5.1.21 instead of 5.x
// due to a MySQL bug (http://bugs.mysql.com/bug.php?id=19588)
if ($this->getServerVersion() >= 5.121) {
$foreign = $this->getForeignConstraints($schemaName, $tableName);
} else {
$foreign = $this->findForeignConstraints($schemaName, $tableName);
}
return array($primary, $foreign);
}