DboSource::alterTableBySchema PHP Method

alterTableBySchema() public method

スキーマファイルからテーブル構造を変更する
public alterTableBySchema ( array $options ) : boolean
$options array [ oldPath / newPath ]
return boolean
    public function alterTableBySchema($options)
    {
        $options = array_merge(array('dropField' => true), $options);
        extract($options);
        if (!isset($oldPath) || !isset($newPath)) {
            return false;
        }
        $oldDir = dirname($oldPath);
        $newDir = dirname($newPath);
        $oldFile = basename($oldPath);
        $newFile = basename($newPath);
        if (!isset($oldName)) {
            $oldName = basename(Inflector::classify($oldFile), '.php');
        }
        if (!isset($newName)) {
            $newName = basename(Inflector::classify($newFile), '.php');
        }
        //App::uses('CakeSchema', 'Model');
        $Schema = ClassRegistry::init('CakeSchema');
        $Schema->connection = $this->configKeyName;
        $old = $Schema->load(array('name' => $oldName, 'path' => $oldDir, 'file' => $oldFile));
        $new = $Schema->load(array('name' => $newName, 'path' => $newDir, 'file' => $newFile));
        if (!$old || !$new) {
            return false;
        }
        return $this->alterTable(array('old' => $old, 'new' => $new, 'dropField' => $dropField));
    }
DboSource