isTableColumn example

$this->tableMapping = $tableMapping;
        $this->typeMapping = $typeMapping;
    }

    /** * {@inheritdoc} */
    public function delete($table$column$updateDependingTables = false)
    {
        $column = $this->formatColumnName($column);

        if (!$this->tableMapping->isTableColumn($table$column)) {
            throw new RuntimeException(sprintf('Table %s has no column with name %s', $table$column));
        }

        $this->schemaOperator->dropColumn($table$column);

        $repository = $this->entityManager->getRepository(Configuration::class);

        $entity = $repository->findOneBy([
            'tableName' => $table,
            'columnName' => $column,
        ]);

        
public function columnNameExistsAction()
    {
        $name = $this->Request()->getParam('columnName');
        $table = $this->Request()->getParam('tableName');

        $mapping = $this->get(TableMappingInterface::class);

        $tables = array_merge([$table]$mapping->getDependingTables($table));

        $table = null;
        foreach ($tables as $attributeTable) {
            if ($mapping->isTableColumn($attributeTable$name)) {
                $table = $attributeTable;
                break;
            }
        }

        $this->View()->assign([
            'exists' => ($table !== null),
            'table' => $table,
        ]);
    }

    
/** * {@inheritdoc} * * @throws \Doctrine\DBAL\DBALException * @throws Exception */
    public function resetColumn($table$column)
    {
        $this->validate($table$column);

        if (!$this->tableMapping->isTableColumn($table$column)) {
            throw new Exception(sprintf('Provided column %s does not exist in table %s', $column$table));
        }

        $sql = sprintf('UPDATE `%s` SET `%s` = NULL', $table$column);
        $this->connection->executeUpdate($sql);
    }

    /** * @param string $table * @param string $name * * @throws Exception */
Home | Imprint | This part of the site doesn't use cookies.