当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Migration::getTableName方法代码示例

本文整理汇总了PHP中Doctrine_Migration::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Migration::getTableName方法的具体用法?PHP Doctrine_Migration::getTableName怎么用?PHP Doctrine_Migration::getTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Migration的用法示例。


在下文中一共展示了Doctrine_Migration::getTableName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateMigrationsFromModels

    /**
     * Generate a set of migrations from a set of models
     *
     * @param  string $modelsPath    Path to models
     * @param  string $modelLoading  What type of model loading to use when loading the models
     * @return boolean
     */
    public function generateMigrationsFromModels($modelsPath = null, $modelLoading = null)
    {
        if ($modelsPath !== null) {
            $models = Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels($modelsPath, $modelLoading));
        } else {
            $models = Doctrine_Core::getLoadedModels();
        }

        $models = Doctrine_Core::initializeModels($models);

        $foreignKeys = array();

        foreach ($models as $model) {
            $table = Doctrine_Core::getTable($model);
            if ($table->getTableName() !== $this->migration->getTableName()) {
                $export = $table->getExportableFormat();

                $foreignKeys[$export['tableName']] = $export['options']['foreignKeys'];

                $up = $this->buildCreateTable($export);
                $down = $this->buildDropTable($export);

                $className = 'Add' . Doctrine_Inflector::classify($export['tableName']);

                $this->generateMigrationClass($className, array(), $up, $down);
            }
        }

        if ( ! empty($foreignKeys)) {
            $className = 'AddFks';

            $up = array();
            $down = array();
            foreach ($foreignKeys as $tableName => $definitions)    {
                $tableForeignKeyNames[$tableName] = array();

                foreach ($definitions as $definition) {
                    $up[] = $this->buildCreateForeignKey($tableName, $definition);
                    $down[] = $this->buildDropForeignKey($tableName, $definition);
                }
            }

            $up = implode("\n", $up);
            $down = implode("\n", $down);
            if ($up || $down) {
                $this->generateMigrationClass($className, array(), $up, $down);
            }
        }

        return true;
    }
开发者ID:nationalfield,项目名称:symfony,代码行数:58,代码来源:Builder.php


注:本文中的Doctrine_Migration::getTableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。