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


PHP Doctrine_Core::initializeModels方法代码示例

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


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

示例1: doExport

 /**
  * doExport
  *
  * FIXME: This function has ugly hacks in it for temporarily disabling INDEXBY query parts of tables 
  * to export.
  *
  * Update from jwage: I am not sure if their is any other better solution for this. It may be the correct
  * solution to disable the indexBy settings for tables when exporting data fixtures. Maybe a better idea 
  * would be to extract this functionality to a pair of functions to enable/disable the index by settings 
  * so simply turn them on and off when they need to query for the translations standalone and don't need 
  * it to be indexed by the lang.
  *
  * @return void
  */
 public function doExport()
 {
     $models = Doctrine_Core::getLoadedModels();
     $specifiedModels = $this->getModels();
     $data = array();
     // for situation when the $models array is empty, but the $specifiedModels array isn't
     if (empty($models)) {
         $models = $specifiedModels;
     }
     $models = Doctrine_Core::initializeModels($models);
     // temporarily disable indexBy query parts of selected and related tables
     $originalIndexBy = array();
     foreach ($models as $name) {
         $table = Doctrine_Core::getTable($name);
         if (!is_null($indexBy = $table->getBoundQueryPart('indexBy'))) {
             $originalIndexBy[$name] = $indexBy;
             $table->bindQueryPart('indexBy', null);
         }
     }
     foreach ($models as $name) {
         if (!empty($specifiedModels) and !in_array($name, $specifiedModels)) {
             continue;
         }
         $results = Doctrine_Core::getTable($name)->findAll();
         if ($results->count() > 0) {
             $data[$name] = $results;
         }
     }
     // Restore the temporarily disabled indexBy query parts
     foreach ($originalIndexBy as $name => $indexBy) {
         Doctrine_Core::getTable($name)->bindQueryPart('indexBy', $indexBy);
     }
     $data = $this->prepareData($data);
     return $this->dumpData($data);
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:49,代码来源:Export.php

示例2: getFullTypeQuery

 public function getFullTypeQuery($type, $alias = 'c', $contentTypeId = null)
 {
     if (is_numeric($type)) {
         $type = Doctrine_Core::getTable('sfSympalContentType')->find($type);
     }
     if ($type instanceof sfSympalContentType) {
         $table = $type->getTable();
         $typeModelName = $type->getName();
     } else {
         $table = Doctrine_Core::getTable($type);
         $typeModelName = $type;
     }
     Doctrine_Core::initializeModels(array($typeModelName));
     $q = $this->getBaseQuery($alias);
     if ($type instanceof sfSympalContentType) {
         $contentTypeId = $type->getId();
     }
     if ($contentTypeId) {
         $q->innerJoin($alias . '.' . $typeModelName . ' cr WITH ' . $alias . '.content_type_id = ' . $contentTypeId);
     } else {
         $q->innerJoin($alias . '.' . $typeModelName . ' cr');
     }
     if (sfSympalConfig::isI18nEnabled($typeModelName)) {
         $q->leftJoin('cr.Translation crt');
     }
     if (method_exists($table, 'getContentQuery')) {
         $table->getContentQuery($q);
     }
     return $q;
 }
开发者ID:bmatychowiak,项目名称:sympal,代码行数:30,代码来源:PluginsfSympalContentTable.class.php

示例3: loadModels

 /**
  * Loads all model classes and returns an array of model names.
  * 
  * @return array An array of model names
  */
 protected function loadModels()
 {
     Doctrine_Core::loadModels($this->configuration->getModelDirs());
     $models = Doctrine_Core::getLoadedModels();
     $models = Doctrine_Core::initializeModels($models);
     $models = Doctrine_Core::filterInvalidModels($models);
     return $models;
 }
开发者ID:cbsistem,项目名称:appflower_studio_playground,代码行数:13,代码来源:sfTaskExtraDoctrineBaseTask.class.php

示例4: _diff

 /**
  * Generate a diff between the from and to schema information
  *
  * @param  string $from     Path to set of models to migrate from
  * @param  string $to       Path to set of models to migrate to
  * @return array  $changes
  */
 protected function _diff($from, $to)
 {
     // Load the from and to models
     $fromModels = Doctrine_Core::initializeModels(Doctrine_Core::loadModels($from));
     $toModels = Doctrine_Core::initializeModels(Doctrine_Core::loadModels($to));
     // Build schema information for the models
     $fromInfo = $this->_buildModelInformation($fromModels);
     $toInfo = $this->_buildModelInformation($toModels);
     // Build array of changes between the from and to information
     $changes = $this->_buildChanges($fromInfo, $toInfo);
     $this->_cleanup();
     return $changes;
 }
开发者ID:szelpe,项目名称:cukorka,代码行数:20,代码来源:Diff.php

示例5: 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:atikahmed,项目名称:joomla-probid,代码行数:46,代码来源:Builder.php

示例6: loadModels

 /**
  * Loads all Doctrine builders.
  */
 protected function loadModels()
 {
     Doctrine_Core::loadModels($this->generatorManager->getConfiguration()->getModelDirs());
     $models = Doctrine_Core::getLoadedModels();
     $models = Doctrine_Core::initializeModels($models);
     $models = Doctrine_Core::filterInvalidModels($models);
     $this->models = $this->filterModels($models);
     return $this->models;
 }
开发者ID:cuongnv540,项目名称:jobeet,代码行数:12,代码来源:sfDoctrineFormGenerator.class.php

示例7: _initializeModels

 /**
  * Initialize some Doctrine models at a given path.
  *
  * @param string $path 
  * @return array $models
  */
 protected function _initializeModels($path)
 {
     $manager = Doctrine_Manager::getInstance();
     $modelLoading = $manager->getAttribute(Doctrine_Core::ATTR_MODEL_LOADING);
     if ($modelLoading === Doctrine_Core::MODEL_LOADING_PEAR) {
         $orig = Doctrine_Core::getModelsDirectory();
         Doctrine_Core::setModelsDirectory($path);
         $models = Doctrine_Core::initializeModels(Doctrine_Core::loadModels($path));
         Doctrine_Core::setModelsDirectory($orig);
     } else {
         $models = Doctrine_Core::initializeModels(Doctrine_Core::loadModels($path));
     }
     return $models;
 }
开发者ID:aldimol,项目名称:zf-sample,代码行数:20,代码来源:Diff.php

示例8: getRecord

 public function getRecord()
 {
     if ($this['Type']['name']) {
         Doctrine_Core::initializeModels(array($this['Type']['name']));
         return $this[$this['Type']['name']];
     } else {
         return false;
     }
 }
开发者ID:bmatychowiak,项目名称:sympal,代码行数:9,代码来源:PluginsfSympalContent.class.php

示例9: loadModels

 /**
  * Load builders
  * 
  * @return  array   Loaded models
  */
 protected function loadModels()
 {
     Doctrine_Core::loadModels(array(sfConfig::get('sf_lib_dir') . '/model'));
     $this->models = $this->filterModels(Doctrine_Core::filterInvalidModels(Doctrine_Core::initializeModels(Doctrine_Core::getLoadedModels())));
     return $this->models;
 }
开发者ID:relo-san,项目名称:dinDoctrineExtraPlugin,代码行数:11,代码来源:dinDoctrineFormFilterGenerator.php

示例10: _initializeModels

 /**
  * Initialize some Doctrine models at a given path.
  *
  * @param string $path 
  * @return array $models
  */
 protected function _initializeModels($path)
 {
     $orig = Doctrine_Core::getModelsDirectory();
     Doctrine_Core::setModelsDirectory($path);
     $models = Doctrine_Core::initializeModels(Doctrine_Core::loadModels($path));
     Doctrine_Core::setModelsDirectory($orig);
     return $models;
 }
开发者ID:adamthedeveloper,项目名称:SFF_MVC,代码行数:14,代码来源:Diff.php

示例11: executeCreate_type

 /**
  * The actual action that handles creating a new piece of content
  * 
  * Uses the new template
  */
 public function executeCreate_type(sfWebRequest $request)
 {
     $type = $request->getParameter('type');
     $this->_getContentType($type, $request);
     $this->sf_sympal_content = new sfSympalContent();
     $this->sf_sympal_content->setType($this->contentType);
     $this->sf_sympal_content->CreatedBy = $this->getUser()->getGuardUser();
     $this->sf_sympal_content->date_published = date('Y-m-d h:i:s');
     Doctrine_Core::initializeModels(array($type['name']));
     $this->form = new sfSympalContentForm($this->sf_sympal_content);
     $this->setTemplate('new');
 }
开发者ID:sympal,项目名称:sympal,代码行数:17,代码来源:Basesympal_contentActions.class.php

示例12: findVersoesArtigo

 public function findVersoesArtigo($artigo)
 {
     Doctrine_Core::initializeModels(array('Artigo'));
     $q = $this->createQuery()->from('ArtigoVersao a')->where('a.id = ?', $artigo)->orderBy('a.version DESC');
     return $q->execute();
 }
开发者ID:kidh0,项目名称:TCControl,代码行数:6,代码来源:ArtigoTable.class.php

示例13: executeCreate_type

 public function executeCreate_type(sfWebRequest $request)
 {
     $type = $request->getParameter('type');
     if (is_numeric($type)) {
         $type = Doctrine_Core::getTable('sfSympalContentType')->find($type);
     } else {
         $type = Doctrine_Core::getTable('sfSympalContentType')->findOneBySlug($type);
     }
     $this->sf_sympal_content = new sfSympalContent();
     $this->sf_sympal_content->setType($type);
     $this->sf_sympal_content->CreatedBy = $this->getUser()->getGuardUser();
     Doctrine_Core::initializeModels(array($type['name']));
     $this->form = new sfSympalContentForm($this->sf_sympal_content);
     $this->setTemplate('new');
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:15,代码来源:Basesympal_contentActions.class.php


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