當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。