DboSource::loadSchema PHP Method

loadSchema() public method

スキーマファイルを利用してテーブルを生成する
public loadSchema ( array $options ) : boolean
$options array path は必須
return boolean
    public function loadSchema($options)
    {
        App::uses('CakeSchema', 'Model');
        $options = array_merge(array('dropField' => true, 'oldSchemaPath' => ''), $options);
        extract($options);
        if (!isset($type)) {
            return false;
        }
        if (!isset($file)) {
            if (isset($table)) {
                $file = $table . '.php';
            } elseif (isset($model)) {
                $file = Inflector::tableize($model) . '.php';
            } elseif (isset($name)) {
                $file = Inflector::underscore($name) . '.php';
            } else {
                return false;
            }
        }
        if (!isset($name)) {
            if (isset($table)) {
                $name = Inflector::camelize($table);
            } elseif (isset($model)) {
                $name = Inflector::pluralize($model);
            } elseif (isset($file)) {
                $name = basename(Inflector::classify($file), '.php');
            } else {
                return false;
            }
        }
        switch ($type) {
            case 'create':
                try {
                    $result = $this->createTableBySchema(array('path' => $path . $file));
                } catch (Exception $e) {
                    $this->log($e->getMessage());
                    $result = false;
                }
                return $result;
                break;
            case 'alter':
                if (!$oldSchemaPath) {
                    $current = $path . basename($file, '.php') . '_current.php';
                    if (!$this->writeCurrentSchema($current)) {
                        return false;
                    }
                } else {
                    $current = $oldSchemaPath;
                }
                try {
                    $result = $this->alterTableBySchema(array('oldPath' => $current, 'newPath' => $path . $file, 'dropField' => $dropField));
                } catch (Exception $e) {
                    $this->log($e->getMessage());
                    $result = false;
                }
                if (!$oldSchemaPath) {
                    unlink($current);
                }
                return $result;
                break;
            case 'drop':
                try {
                    $result = $this->dropTableBySchema(array('path' => $path . $file));
                } catch (Exception $e) {
                    $this->log($e->getMessage());
                    $result = false;
                }
                return $result;
                break;
        }
        return false;
    }
DboSource