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


PHP Doctrine::loadModel方法代码示例

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


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

示例1: buildDBFromModels

 /**
  * Rebuilds a db as described by the doctrine models
  *
  */
 public function buildDBFromModels()
 {
     $icinga = $this->project->getUserProperty("PATH_Icinga");
     $modelPath = $icinga . "/app/modules/" . $this->project->getUserProperty("MODULE_Name") . "/lib/";
     $appKitPath = $this->project->getUserProperty("PATH_AppKit");
     Doctrine::loadModels($icinga . "/" . $appKitPath . "database/models/generated/");
     Doctrine::loadModel($icinga . "/" . $appKitPath . "database/models/");
     $tables = Doctrine::getLoadedModels();
     $tableList = array();
     foreach ($tables as $table) {
         $tableList[] = Doctrine::getTable($table)->getTableName();
     }
     Doctrine::createTablesFromModels(array($this->models . '/generated', $this->models));
     file_put_contents($modelPath . "/.models.cfg", implode(",", $tableList));
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:19,代码来源:doctrineDBBuilderTask.php

示例2: setUp

 public function setUp()
 {
     try {
         //Load path configs
         $root_path = str_replace('test', '', dirname(__FILE__));
         $docCfg = Zend_Registry::get('config')->doctrine->toArray();
         foreach ($docCfg as &$cfg) {
             $cfg = str_replace("{ROOT_PATH}", $root_path, $cfg);
         }
         //Generate Database structure for tests
         $this->tearDown();
         Doctrine::createDatabases();
         Doctrine::createTablesFromModels($docCfg['models_path']);
         Doctrine::loadModel($docCfg['models_path']);
         Doctrine::loadData($docCfg['data_fixtures_path']);
         Util_Log::get()->UnitTests()->debug('Executed Env SetUp');
     } catch (Exception $e) {
         Util_Log::get()->UnitTests()->debug('Failed Setting up environment');
         Util_Log::get()->UnitTests()->err($e->getMessage());
     }
 }
开发者ID:rdohms,项目名称:ugDirectory,代码行数:21,代码来源:AllTests.php

示例3: writeDefinition

 /**
  * writeDefinition
  *
  * @param array $options
  * @param array $columns
  * @param array $relations
  * @param array $indexes
  * @param array $attributes
  * @param array $templates
  * @param array $actAs
  * @return void
  */
 public function writeDefinition(array $definition)
 {
     $definitionCode = $this->buildDefinition($definition);
     $fileName = $definition['className'] . $this->_suffix;
     $packagesPath = $this->_packagesPath ? $this->_packagesPath : $this->_path;
     // If this is a main class that either extends from Base or Package class
     if (isset($definition['is_main_class']) && $definition['is_main_class']) {
         // If is package then we need to put it in a package subfolder
         if (isset($definition['is_package']) && $definition['is_package']) {
             $writePath = $this->_path . DIRECTORY_SEPARATOR . $definition['package_name'];
             // Otherwise lets just put it in the root of the path
         } else {
             $writePath = $this->_path;
         }
         if ($this->generateTableClasses()) {
             $this->writeTableDefinition($definition['tableClassName'], $writePath, array('extends' => $definition['inheritance']['tableExtends']));
         }
     } else {
         if (isset($definition['is_package_class']) && $definition['is_package_class']) {
             if (isset($definition['package_custom_path'])) {
                 $writePath = $definition['package_custom_path'];
             } else {
                 $writePath = $packagesPath . DIRECTORY_SEPARATOR . $definition['package_path'];
             }
             if ($this->generateTableClasses()) {
                 $this->writeTableDefinition($definition['tableClassName'], $writePath, array('extends' => $definition['inheritance']['tableExtends']));
             }
         } else {
             if (isset($definition['is_base_class']) && $definition['is_base_class']) {
                 // If it is a part of a package then we need to put it in a package subfolder
                 if (isset($definition['is_package']) && $definition['is_package']) {
                     $basePath = $this->_path . DIRECTORY_SEPARATOR . $definition['package_name'];
                     $writePath = $basePath . DIRECTORY_SEPARATOR . $this->_baseClassesDirectory;
                     // Otherwise lets just put it in the root generated folder
                 } else {
                     $writePath = $this->_path . DIRECTORY_SEPARATOR . $this->_baseClassesDirectory;
                 }
             }
         }
     }
     // If we have a writePath from the if else conditionals above then use it
     if (isset($writePath)) {
         Doctrine_Lib::makeDirectories($writePath);
         $writePath .= DIRECTORY_SEPARATOR . $fileName;
         // Otherwise none of the conditions were met and we aren't generating base classes
     } else {
         Doctrine_Lib::makeDirectories($this->_path);
         $writePath = $this->_path . DIRECTORY_SEPARATOR . $fileName;
     }
     $code = "<?php" . PHP_EOL;
     if (isset($definition['connection']) && $definition['connection']) {
         $code .= "// Connection Component Binding" . PHP_EOL;
         $code .= "Doctrine_Manager::getInstance()->bindComponent('" . $definition['connectionClassName'] . "', '" . $definition['connection'] . "');" . PHP_EOL;
     }
     $code .= PHP_EOL . $definitionCode;
     if (isset($definition['generate_once']) && $definition['generate_once'] === true) {
         if (!file_exists($writePath)) {
             $bytes = file_put_contents($writePath, $code);
         }
     } else {
         $bytes = file_put_contents($writePath, $code);
     }
     if (isset($bytes) && $bytes === false) {
         throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $writePath);
     }
     Doctrine::loadModel($definition['className'], $writePath);
 }
开发者ID:silky,项目名称:littlesis,代码行数:79,代码来源:Builder.php

示例4: _loadDoctrineModels

 /**
  * Let doctrine load its models
  * 
  * @return void
  */
 protected function _loadDoctrineModels()
 {
     $models = $this->_getModels();
     foreach ($models as $model) {
         $cleanModel = str_replace($this->getModulePath() . DIRECTORY_SEPARATOR, '', $model);
         $cleanModel = str_replace('.php', '', $cleanModel);
         /*
          * 0 => modulename
          * 1 => models
          * 2 => model base name
          */
         $classnameParts = explode(DIRECTORY_SEPARATOR, $cleanModel);
         $classname = ucfirst($classnameParts[0]) . '_Model_' . $classnameParts[2];
         if (class_exists($classname) && is_subclass_of($classname, 'Doctrine_Record')) {
             Doctrine::loadModel($classname, $model);
         }
     }
 }
开发者ID:KasaiDot,项目名称:FansubCMS,代码行数:23,代码来源:DoctrineTool.php


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