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


PHP Doctrine_Core::loadModels方法代码示例

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


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

示例1: _initDoctrine

 protected function _initDoctrine()
 {
     $config = $this->getOptions();
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
     $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_CHARSET, 'utf8');
     $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_COLLATE, 'utf8_unicode_ci');
     $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_TYPE, 'INNODB');
     $manager->setAttribute(Doctrine_Core::ATTR_USE_NATIVE_ENUM, true);
     $manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, false);
     $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     // enable validation on save()
     $manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);
     $manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
     if ($config['doctrine']['cache']) {
         $cacheDriver = new Doctrine_Cache_Apc();
         $manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver);
     }
     $conn = Doctrine_Manager::connection($config['doctrine']['dsn']);
     $conn->setCharset('utf8');
     try {
         Doctrine_Core::createDatabases();
     } catch (Exception $e) {
     }
     $conn = Doctrine_Core::loadModels(APPLICATION_PATH . '/models', Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
     $conn = Doctrine_Core::createTablesFromModels();
     return $manager;
 }
开发者ID:kenncapara,项目名称:emaxx,代码行数:28,代码来源:Bootstrap.php

示例2: testTest

 public function testTest()
 {
     $models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $this->assertEqual($models1, $models2);
     $models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1');
     $models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1');
     $this->assertEqual($models1, $models2);
     $models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $this->assertEqual($models1, $models2);
     $models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $this->assertEqual($models1, $models2);
     $models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2');
     $models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2');
     $this->assertEqual($models1, $models2);
     $models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $this->assertEqual($models1, $models2);
     $models1 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'));
     $models2 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'));
     $this->assertEqual($models1, $models2);
     $models1 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'), Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $models2 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'), Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $this->assertEqual($models1, $models2);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:27,代码来源:1727TestCase.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: __construct

 /**
  * Constructor
  *
  * Initialize things.
  *
  */
 function __construct()
 {
     if (null == self::$_appInstance) {
         self::$_appInstance = Slim::getInstance();
     }
     Doctrine_Core::loadModels(MODELS_PATH);
     DoctrineAdapter::getInstance();
 }
开发者ID:edupol,项目名称:examsystem,代码行数:14,代码来源:DoctrineBaseClass.php

示例5: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->logSection('doctrine', 'created tables successfully');
     $databaseManager = new sfDatabaseManager($this->configuration);
     $config = $this->getCliConfig();
     Doctrine_Core::loadModels($config['models_path'], Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     Doctrine_Core::createTablesFromArray(Doctrine_Core::getLoadedModels());
 }
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:11,代码来源:sfDoctrineInsertSqlTask.class.php

示例6: testConservativeModelLoading

 public function testConservativeModelLoading()
 {
     $path = realpath('ModelLoadingTest/Conservative');
     $models = Doctrine_Core::loadModels($path, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     $this->assertTrue(!class_exists('ConservativeModelLoadingUser', false));
     $this->assertTrue(!class_exists('ConservativeModelLoadingProfile', false));
     $this->assertTrue(!class_exists('ConservativeModelLoadingContact', false));
     $this->assertTrue(!class_exists('BaseConservativeModelLoadingUser', false));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:9,代码来源:BaseTestCase.php

示例7: execute

 public function execute()
 {
     Doctrine_Core::loadModels($this->getArgument('models_path'));
     $dql = $this->getArgument('dql_query');
     $query = Doctrine_Query::create();
     $params = $this->getArgument('params');
     $params = $params ? explode(',', $params) : array();
     $this->notify('executing: "' . $dql . '" (' . implode(', ', $params) . ')');
     $results = $query->query($dql, $params, Doctrine_Core::HYDRATE_ARRAY);
     $this->_printResults($results);
 }
开发者ID:arenatournament,项目名称:geek-land,代码行数:11,代码来源:Dql.php

示例8: loadModels

 /**
  * @param array|string $directories
  * @return array
  */
 public static function loadModels($directories, $modelLoading = null, $classPrefix = null)
 {
     $manager = Doctrine_Manager::getInstance();
     $modelLoading = $modelLoading != null ? $manager->getAttribute(Doctrine_Core::ATTR_MODEL_LOADING) : $modelLoading;
     $zendStyles = array(self::MODEL_LOADING_ZEND, self::MODEL_LOADING_ZEND_SINGLE_LIBRARY, self::MODEL_LOADING_ZEND_MODULE_LIBRARY);
     if (in_array($modelLoading, $zendStyles)) {
         return self::loadAllZendModels();
     } else {
         return parent::loadModels($directories, $modelLoading, $classPrefix);
     }
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:15,代码来源:Core.php

示例9: _initDoctrine

 protected function _initDoctrine()
 {
     $this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine', 'autoload'));
     spl_autoload_register(array('Doctrine', 'modelsAutoload'));
     $doctrineConfig = $this->getOption('doctrine');
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
     $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, $doctrineConfig['model_autoloading']);
     Doctrine_Core::loadModels($doctrineConfig['models_path']);
     $conn = Doctrine_Manager::connection($doctrineConfig['dsn'], 'doctrine');
     $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
     return $conn;
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:13,代码来源:Bootstrap.php

示例10: setUp

 static function setUp()
 {
     try {
         Doctrine_Core::dropDatabases();
     } catch (Exception $e) {
     }
     Doctrine_Manager::connection()->clear();
     try {
         Doctrine_Core::createDatabases();
     } catch (Exception $e) {
     }
     Doctrine_Core::loadModels(APPLICATION_PATH . '/models', Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
     Doctrine_Core::createTablesFromModels();
 }
开发者ID:kenncapara,项目名称:emaxx,代码行数:14,代码来源:bootstrap.php

示例11: _initDoctrine

 public function _initDoctrine()
 {
     require_once 'Doctrine.php';
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->pushAutoloader(array('Doctrine', 'autoload'));
     $doctrineConfig = $this->getOption('doctrine');
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
     $manager->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
     $manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
     Doctrine_Core::loadModels($doctrineConfig['models_path'] . '/generated');
     Doctrine_Core::loadModels($doctrineConfig['models_path']);
     $conn = Doctrine_Manager::connection($doctrineConfig['connection_string'], 'doctrine');
     return $manager;
 }
开发者ID:valentinbora,项目名称:gasestema,代码行数:15,代码来源:Bootstrap.php

示例12: testTest

 public function testTest()
 {
     $models1Dir = dirname(__FILE__) . '/2375/models1';
     $models2Dir = dirname(__FILE__) . '/2375/models2';
     // try loading a couple initial models
     $models1 = Doctrine_Core::loadModels($models1Dir);
     //$models2 = Doctrine_Core::loadModels($models2Dir);
     // make sure two models were loaded
     $this->assertEqual(2, count($models1));
     // make sure the right models were loaded
     $this->assertTrue(key_exists('Ticket_2375_Model1', $models1));
     $this->assertTrue(key_exists('Ticket_2375_Model2', $models1));
     // get a list of all models that have been loaded
     $loadedModels = Doctrine_Core::getLoadedModelFiles();
     // make sure the paths are correct
     $this->assertEqual($loadedModels['Ticket_2375_Model1'], $models1Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model1.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model2'], $models1Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model2.php');
     // try loading a few more models
     $models2 = Doctrine_Core::loadModels($models2Dir);
     // make sure the right models were loaded
     $this->assertTrue(key_exists('Ticket_2375_Model3', $models2));
     $this->assertTrue(key_exists('Ticket_2375_Model4', $models2));
     $this->assertTrue(key_exists('Ticket_2375_Model5', $models2));
     $this->assertTrue(key_exists('Ticket_2375_Model6', $models2));
     // get a list of all models that have been loaded
     $loadedModels = Doctrine_Core::getLoadedModelFiles();
     // make sure the paths are correct
     $this->assertEqual($loadedModels['Ticket_2375_Model1'], $models1Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model1.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model2'], $models1Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model2.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model3'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model3.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model4'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model4.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model5'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model5.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model6'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model5.php');
     // try loading the first models again
     $models1 = Doctrine_Core::loadModels($models1Dir);
     // make sure the right models were loaded
     $this->assertTrue(key_exists('Ticket_2375_Model1', $models1));
     $this->assertTrue(key_exists('Ticket_2375_Model2', $models1));
     // get a list of all models that have been loaded
     $loadedModels = Doctrine_Core::getLoadedModelFiles();
     // make sure the paths are correct
     $this->assertEqual($loadedModels['Ticket_2375_Model1'], $models1Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model1.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model2'], $models1Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model2.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model3'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model3.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model4'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model4.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model5'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model5.php');
     $this->assertEqual($loadedModels['Ticket_2375_Model6'], $models2Dir . DIRECTORY_SEPARATOR . 'Ticket_2375_Model5.php');
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:48,代码来源:2375TestCase.php

示例13: _initDoctrine

 protected function _initDoctrine()
 {
     $this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine', 'autoload'));
     spl_autoload_register(array('Doctrine', 'modelsAutoload'));
     // with the help of it generate sql and write in it.
     $doctrineConfig = $this->getOption('doctrine');
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
     $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, $doctrineConfig['model_autoloading']);
     $manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
     Doctrine_Core::loadModels($doctrineConfig['models_path']);
     // this loads all model classes.
     $conn = Doctrine_Manager::connection($doctrineConfig['dsn'], 'doctrine');
     $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
     return $conn;
 }
开发者ID:nainit-virtueinfo,项目名称:zend-rest,代码行数:16,代码来源:Bootstrap.php

示例14: loadModels

 /**
  * Aggressively load models.
  *
  * This helper is required because we are using PEAR naming standards with
  * our own autoloading.  Doctrine's model loading doesn't take this into
  * account in non agressive modes.
  *
  * In general, this method is NOT required.
  *
  * @param string $modname Module name to load models for.
  *
  * @return void
  */
 public static function loadModels($modname)
 {
     $modname = isset($modname) ? strtolower((string) $modname) : '';
     $modinfo = ModUtil::getInfoFromName($modname);
     $osdir = DataUtil::formatForOS($modinfo['directory']);
     $base = $modinfo['type'] == ModUtil::TYPE_MODULE ? 'modules' : 'system';
     $dm = Doctrine_Manager::getInstance();
     $save = $dm->getAttribute(Doctrine_Core::ATTR_MODEL_LOADING);
     $dm->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
     $path = "{$base}/{$osdir}/lib/{$osdir}/Model";
     // prevent exception when model folder does not exist
     if (file_exists($path)) {
         Doctrine_Core::loadModels(realpath($path));
     }
     $dm->setAttribute(Doctrine::ATTR_MODEL_LOADING, $save);
 }
开发者ID:planetenkiller,项目名称:core,代码行数:29,代码来源:DoctrineUtil.php

示例15: flushDatabase

 /** Flush the database and reload base fixtures.
  *
  * @param bool $rebuild
  *  true:   The database will be dropped and rebuilt.
  *  false:  The method will try just to flush the data.
  *
  * Note that the first time flushDatabase() is called (per execution), the
  *  database will be rebuilt regardless of $rebuild.
  *
  * @return static
  */
 public function flushDatabase($rebuild = false)
 {
     if ($this->_connection) {
         /* The first time we run a test case, drop and rebuild the database.
          *
          * After that, we can simply truncate all tables for speed.
          */
         if (empty(self::$_dbRebuilt) or $rebuild) {
             /* Don't try to drop the database unless it exists. */
             $name = $this->getDatabaseName();
             /** @noinspection PhpUndefinedFieldInspection */
             if ($name and $this->_connection->import->databaseExists($name)) {
                 $this->_connection->dropDatabase();
             }
             $this->_connection->createDatabase();
             Doctrine_Core::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
             Doctrine_Core::createTablesFromArray(Doctrine_Core::getLoadedModels());
             self::$_dbRebuilt = true;
         } else {
             /* Determine the order we need to load models. */
             if (!isset(self::$_dbFlushTree)) {
                 /** @noinspection PhpUndefinedFieldInspection */
                 $models = $this->_connection->unitOfWork->buildFlushTree(Doctrine_Core::getLoadedModels());
                 self::$_dbFlushTree = array_reverse($models);
             }
             $this->_doPreFlush();
             /* Delete records, paying special attention to SoftDelete. */
             foreach (self::$_dbFlushTree as $model) {
                 $table = Doctrine_Core::getTable($model);
                 if ($table->hasTemplate('SoftDelete')) {
                     /** @var $record Doctrine_Template_SoftDelete */
                     foreach ($table->createQuery()->execute() as $record) {
                         $record->hardDelete();
                     }
                 }
                 $table->createQuery()->delete()->execute();
                 $table->clear();
             }
             $this->_doPostFlush();
             /** Clear all Doctrine table repositories to prevent memory leaks
              *    between tests.
              */
             $this->_connection->clear();
         }
     }
     return $this;
 }
开发者ID:todofixthis,项目名称:sfJwtPhpUnitPlugin,代码行数:58,代码来源:Driver.class.php


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