public function getDropTableDDL(Table $table) { $ret = "\r\nDROP TABLE " . $this->quoteIdentifier($table->getName()) . " CASCADE CONSTRAINTS;\r\n"; if ($table->getIdMethod() == IDMethod::NATIVE) { $ret .= "\r\nDROP SEQUENCE " . $this->quoteIdentifier($this->getSequenceName($table)) . ";\r\n"; } return $ret; }
protected function getDropSequenceDDL(Table $table) { if ($table->getIdMethod() == IDMethod::NATIVE && $table->getIdMethodParameters() != null) { $pattern = "\nDROP SEQUENCE %s;\n"; return sprintf($pattern, $this->quoteIdentifier(strtolower($this->getSequenceName($table)))); } }
/** * Gets the name to use for creating a sequence for a table. * * This will create a new name or use one specified in an id-method-parameter * tag, if specified. * * @param Table $table * * @return string Sequence name for this table. */ public function getSequenceName(Table $table) { static $longNamesMap = array(); $result = null; if ($table->getIdMethod() == IDMethod::NATIVE) { $idMethodParams = $table->getIdMethodParameters(); $maxIdentifierLength = $this->getMaxColumnNameLength(); if (empty($idMethodParams)) { if (strlen($table->getName() . "_SEQ") > $maxIdentifierLength) { if (!isset($longNamesMap[$table->getName()])) { $longNamesMap[$table->getName()] = strval(count($longNamesMap) + 1); } $result = substr($table->getName(), 0, $maxIdentifierLength - strlen("_SEQ_" . $longNamesMap[$table->getName()])) . "_SEQ_" . $longNamesMap[$table->getName()]; } else { $result = substr($table->getName(), 0, $maxIdentifierLength - 4) . "_SEQ"; } } else { $result = substr($idMethodParams[0]->getValue(), 0, $maxIdentifierLength); } } return $result; }