/** * @param PlatformInterface|null $adapterPlatform * @return string */ public function getSqlString(PlatformInterface $adapterPlatform = null) { $sql = parent::getSqlString($adapterPlatform); if (empty($options = $this->subject->getOptions())) { return $sql; } $chooseOptions = []; foreach ($options as $option => $value) { if (is_int($option)) { $option = $value; } switch ($this->normalizeCommandOption($option)) { case 'restart': case 'restartidentity': if (!in_array('CONTINUE IDENTITY', $chooseOptions)) { $chooseOptions[] = 'RESTART IDENTITY'; } break; case 'continue': case 'continueidentity': if (!in_array('RESTART IDENTITY', $chooseOptions)) { $chooseOptions[] = 'CONTINUE IDENTITY'; } break; case 'cascade': if (!in_array('RESTRICT', $chooseOptions)) { $chooseOptions[] = 'CASCADE'; } break; case 'restrict': if (!in_array('CASCADE', $chooseOptions)) { $chooseOptions[] = 'RESTRICT'; } break; } } $sql .= ' ' . implode(' ', $chooseOptions); return $sql; }
/** * @param string $tableName * @param array|null $options * @return TruncateTable */ public function truncateTable($tableName, array $options = null) { $table = new TruncateTable($tableName); if (is_array($options)) { $table->setOptions($options); } return $table; }