- public function dropForeignKey($tableName, $fkName, $schemaName = null)
- {
- $foreignKeys = $this->getForeignKeys($tableName, $schemaName);
- $fkName = strtoupper($fkName);
- if (substr($fkName, 0, 3) == 'FK_') {
- $fkName = substr($fkName, 3);
- }
- foreach ([$fkName, 'FK_' . $fkName] as $key) {
- if (isset($foreignKeys[$key])) {
- $sql = sprintf(
- 'ALTER TABLE %s DROP FOREIGN KEY %s',
- $this->quoteIdentifier($this->_getTableName($tableName, $schemaName)),
- $this->quoteIdentifier($foreignKeys[$key]['FK_NAME'])
- );
- $this->resetDdlCache($tableName, $schemaName);
- $this->rawQuery($sql);
- }
- }
- return $this;
- }