src/Phinx/Db/Adapter/SQLiteAdapter.php
protected function calculateNewTableColumns($tableName, $columnName, $newColumnName)
    {
        $columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName)));
        $selectColumns = [];
        $writeColumns = [];
        $columnType = null;
        $found = false;

        foreach ($columns as $column) {
            $selectName = $column['name'];
            $writeName = $selectName;

            if ($selectName == $columnName) {
                $writeName = $newColumnName;
                $found = true;
                $columnType = $column['type'];
                $selectName = $newColumnName === false ? $newColumnName : $selectName;
            }

            $selectColumns[] = $selectName;
            $writeColumns[] = $writeName;
        }

        $selectColumns = array_filter($selectColumns, 'strlen');
        $writeColumns = array_filter($writeColumns, 'strlen');
        $selectColumns = array_map([$this, 'quoteColumnName'], $selectColumns);
        $writeColumns = array_map([$this, 'quoteColumnName'], $writeColumns);

        if (!$found) {
            throw new \InvalidArgumentException(sprintf(
                'The specified column doesn\'t exist: ' . $columnName
            ));
        }

        return compact('writeColumns', 'selectColumns', 'columnType');
    }
protected function calculateNewTableColumns($tableName, $columnName, $newColumnName)
    {
        $columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName)));
        $selectColumns = [];
        $writeColumns = [];
        $columnType = null;
        $found = false;

        foreach ($columns as $column) {
            $selectName = $column['name'];
            $writeName = $selectName;

            if ($selectName == $columnName) {
                $writeName = $newColumnName;
                $found = true;
                $columnType = $column['type'];
                $selectName = $newColumnName === false ? $newColumnName : $selectName;
            }

            $selectColumns[] = $selectName;
            $writeColumns[] = $writeName;
        }

        $selectColumns = array_filter($selectColumns, 'strlen');
        $writeColumns = array_filter($writeColumns, 'strlen');
        $selectColumns = array_map([$this, 'quoteColumnName'], $selectColumns);
        $writeColumns = array_map([$this, 'quoteColumnName'], $writeColumns);

        if (!$found) {
            throw new \InvalidArgumentException(sprintf(
                'The specified column doesn\'t exist: ' . $columnName
            ));
        }

        return compact('writeColumns', 'selectColumns', 'columnType');
    }
protected function calculateNewTableColumns ( $ tableName , $ columnName , $ newColumnName ) { $ columns = $ this -> fetchAll ( sprintf ( 'pragma table_info(%s)' , $ this -> quoteTableName ( $ tableName ) ) ) ; $ selectColumns = [ ] ; $ writeColumns = [ ] ; $ columnType = null ; $ found = false ; foreach ( $ columns as $ column ) { $ selectName = $ column [ 'name' ] ; $ writeName = $ selectName ; if ( $ selectName == $ columnName ) { $ writeName = $ newColumnName ; $ found = true ; $ columnType = $ column [ 'type' ] ; $ selectName = $ newColumnName === false ? $ newColumnName : $ selectName ; } $ selectColumns [ ] = $ selectName ; $ writeColumns [ ] = $ writeName ; } $ selectColumns = array_filter ( $ selectColumns , 'strlen' ) ; $ writeColumns = array_filter ( $ writeColumns , 'strlen' ) ; $ selectColumns = array_map ( [ $ this , 'quoteColumnName' ] , $ selectColumns ) ; $ writeColumns = array_map ( [ $ this , 'quoteColumnName' ] , $ writeColumns ) ; if ( ! $ found ) { throw new \ InvalidArgumentException ( sprintf ( 'The specified column doesn\'t exist: ' . $ columnName ) ) ; } return compact ( 'writeColumns' , 'selectColumns' , 'columnType' ) ; }
Returns the columns and type to use when copying a table to another in the process
of altering a table

@param string $tableName The table to modify
@param string $columnName The column name that is about to change
@param string|false $newColumnName Optionally the new name for the column
@return AlterInstructions
Returns the columns and type to use when copying a table to another in the process of altering a table