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


PHP Doctrine_Core::setModelsDirectory方法代码示例

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


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

示例1: _initDoctrine

 public function _initDoctrine()
 {
     $this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine', 'autoload'));
     spl_autoload_register(array('Doctrine', 'modelsAutoload'));
     $manager = Doctrine_Manager::getInstance();
     $config = $this->getOption('doctrine');
     Doctrine_Core::setModelsDirectory($config['models_path']);
     $connection = Doctrine_Manager::connection($config['dsn'], 'doctrine');
     $profiler = new Doctrine_Connection_Profiler();
     $connection->setListener($profiler);
 }
开发者ID:jalbertbowden,项目名称:twiliokit,代码行数:11,代码来源:bootstrap.php

示例2: testClassExistsAfterImport

 public function testClassExistsAfterImport()
 {
     Doctrine_Core::setModelsDirectory(dirname(__FILE__) . '/DC95/models');
     $import = new Doctrine_Import_Schema();
     $import->setOptions(array('pearStyle' => true, 'baseClassesDirectory' => null, 'baseClassPrefix' => 'Base_', 'classPrefix' => 'DC95_', 'classPrefixFiles' => true));
     $modelsPath = dirname(__FILE__) . '/DC95/models';
     $import->importSchema(dirname(__FILE__) . '/DC95/schema.yml', 'yml', $modelsPath);
     /*
     $this->assertTrue(file_exists($modelsPath . '/DC95/Base/Article.php'));
     $this->assertTrue(file_exists($modelsPath . '/DC95/Base/Article/Category.php'));
     $this->assertTrue(file_exists($modelsPath . '/DC95/Article.php'));
     $this->assertTrue(file_exists($modelsPath . '/DC95/Article/Category.php'));
     */
     Doctrine_Core::setModelsDirectory(null);
     Doctrine_Lib::removeDirectories(dirname(__FILE__) . '/DC95/models');
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:16,代码来源:DC95TestCase.php

示例3: registerDoctrine

 public static function registerDoctrine()
 {
     if (self::$doctrineLoaded) {
         return;
     }
     $settings = sgConfiguration::get('settings.DoctrinePlugin');
     Doctrine_Core::setExtensionsPath(self::getPath('extensions'));
     Doctrine_Core::setModelsDirectory(self::getPath('models'));
     $manager = Doctrine_Manager::getInstance();
     $manager->openConnection($settings['dsn'], 'doctrine');
     if (isset($settings['attributes'])) {
         foreach ($settings['attributes'] as $attribute => $value) {
             $manager->setAttribute($attribute, $value);
         }
     }
     self::$doctrineLoaded = true;
 }
开发者ID:superglue,项目名称:DoctrinePlugin,代码行数:17,代码来源:DoctrinePluginConfiguration.class.php

示例4: __construct

 function __construct()
 {
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
     Doctrine_Core::setModelsDirectory(MODELS_PATH);
     if (!self::$_dbConnection) {
         try {
             self::$_dbConnection = Doctrine_Manager::connection(new PDO($this->_dbtype . ':host=' . $this->_host . ';port=' . $this->_port . ';dbname=' . $this->_dbName, $this->_dbUser, $this->_dbPwd, $this->_db_params));
         } catch (PDOException $e) {
             self::$_dbConnection = null;
             /* error message output */
             if ($this->_production_mode === true) {
                 file_put_contents('dortine_errors.log', $e->getMessage(), FILE_APPEND);
                 // log the errors
                 die($e->getMessage());
             } else {
                 die($e->getMessage());
             }
         }
         // end try
     }
     // end if
 }
开发者ID:edupol,项目名称:examsystem,代码行数:23,代码来源:DoctrineAdapter.php

示例5: define

define('SANDBOX_PATH', dirname(__FILE__));
define('BASEPATH', dirname(__FILE__));
define('DOCTRINE_PATH', APP_PATH . DS . 'plugins' . DS . 'doctrine' . DS . 'lib');
define('DATA_FIXTURES_PATH', dirname(SANDBOX_PATH) . DS . 'orm' . DS . 'fixtures');
define('MODELS_PATH', APP_PATH . DS . 'models');
define('MIGRATIONS_PATH', dirname(SANDBOX_PATH) . DS . 'orm' . DS . 'migrations');
define('SQL_PATH', dirname(SANDBOX_PATH) . DS . 'orm' . DS . 'sql');
define('YAML_SCHEMA_PATH', dirname(SANDBOX_PATH) . DS . 'orm' . DS . 'schema/schema.yml');
//define('DB_PATH', SANDBOX_PATH . DS . 'sandbox.db');
define('DSN', 'mysql://root:strato1986@localhost/db_lola');


require_once(DOCTRINE_PATH . DS . 'Doctrine.php');
require_once APP_PATH . DS . 'config' . DS . 'database.php';

Doctrine_Core::setModelsDirectory(MODELS_PATH); 
//Doctrine_Core::setExtensionsPath(dirname(__FILE__).'/extensions');

spl_autoload_register(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
//spl_autoload_register(array('Doctrine', 'extensionsAutoload'));

$manager = Doctrine_Manager::getInstance();

//$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_PEAR);

        $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
        $manager->setAttribute(
          Doctrine::ATTR_MODEL_LOADING,
          DOctrine::MODEL_LOADING_CONSERVATIVE
        );
开发者ID:nahue,项目名称:LolaRestoBar,代码行数:31,代码来源:config.php

示例6: define

 *
 * This is a sample implementation of Doctrine
 * 
 * @package     Doctrine
 * @subpackage  Config
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @link        www.phpdoctrine.org
 * @since       1.0
 * @version     $Revision: 2753 $
 * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
 * @author      Jonathan H. Wage <jwage@mac.com>
 */
define('SANDBOX_PATH', dirname(__FILE__));
define('DOCTRINE_PATH', dirname(dirname(SANDBOX_PATH)) . DIRECTORY_SEPARATOR . 'lib');
define('DATA_FIXTURES_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'fixtures');
define('MODELS_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'models');
define('MIGRATIONS_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'migrations');
define('SQL_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sql');
define('YAML_SCHEMA_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'schema');
define('DB_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'sandbox.db');
define('DSN', 'sqlite:///' . DB_PATH);
require_once DOCTRINE_PATH . DIRECTORY_SEPARATOR . 'Doctrine.php';
Doctrine_Core::setExtensionsPath(dirname(__FILE__) . '/extensions');
spl_autoload_register(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
spl_autoload_register(array('Doctrine', 'extensionsAutoload'));
$manager = Doctrine_Manager::getInstance();
$manager->openConnection(DSN, 'doctrine');
$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_PEAR);
Doctrine_Core::setModelsDirectory('models');
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:30,代码来源:config.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: initialize

 /**
  * Initialize Doctrine set the autoloading
  *
  * @param      AgaviDatabaseManager The database manager of this instance.
  * @param      array                An assoc array of initialization params.
  *
  * @author     David Zülke <dz@bitxtender.com>
  * @author     Ross Lawley <ross.lawley@gmail.com>
  * @author     TANAKA Koichi <tanaka@ensites.com>
  * @since      0.11.0
  */
 public function initialize(AgaviDatabaseManager $databaseManager, array $parameters = array())
 {
     parent::initialize($databaseManager, $parameters);
     $name = $this->getName();
     // try to autoload doctrine
     if (!class_exists('Doctrine')) {
         // okay that didn't work. last resort: include it. we assume it's on the include path by default
         require 'Doctrine.php';
     }
     $is12 = version_compare(Doctrine::VERSION, '1.2', '>=');
     // in any case, it's loaded now. maybe we need to register the autoloading stuff for it!
     // we need this list further down
     $splAutoloadFunctions = spl_autoload_functions();
     if (!in_array(array('Doctrine', 'autoload'), $splAutoloadFunctions) && !in_array(array('Doctrine_Core', 'autoload'), $splAutoloadFunctions)) {
         // we do
         spl_autoload_register(array('Doctrine', 'autoload'));
     }
     // cool. Assign the Doctrine Manager instance
     $this->doctrineManager = Doctrine_Manager::getInstance();
     // now we're in business. we will set up connections right away, as Doctrine is handling the lazy-connecting stuff for us.
     // that way, you can just start using classes in your code
     try {
         $dsn = $this->getParameter('dsn');
         if ($dsn === null) {
             // missing required dsn parameter
             $error = 'Database configuration specifies method "dsn", but is missing dsn parameter';
             throw new AgaviDatabaseException($error);
         }
         $this->connection = $this->doctrineManager->openConnection($dsn, $name);
         // do not assign the resource here. that would connect to the database
         // $this->resource = $this->connection->getDbh();
         // set our event listener that, on connect, sets the configured charset and runs init queries
         $this->connection->setListener(new AgaviDoctrineDatabaseEventListener($this));
         $this->connection->setPrefix($this->getParameter('prefix', ""));
         // set the context instance as a connection parameter
         $this->connection->setParam('context', $databaseManager->getContext(), 'org.agavi');
         // date format
         if ($this->hasParameter('date_format')) {
             $this->connection->setDateFormat($this->getParameter('date_format'));
         }
         // options
         foreach ((array) $this->getParameter('options') as $optionName => $optionValue) {
             $this->connection->setOption($optionName, $optionValue);
         }
         foreach (array('manager_attributes' => $this->doctrineManager, 'attributes' => $this->connection) as $attributesKey => $attributesDestination) {
             foreach ((array) $this->getParameter($attributesKey, array()) as $attributeName => $attributeValue) {
                 if ($is12) {
                     if (!strpos($attributeName, '::')) {
                         throw new AgaviDatabaseException(sprintf('For Doctrine 1.2 and newer, attribute names (and, if desired to be resolved against a constant, values) must be fully qualified, e.g. "Doctrine_Core::ATTR_VALIDATE" and "Doctrine_Core::VALIDATE_NONE". Given attribute with name "%s" in collection "%s" does not match this condition.', $attributeName, $attributesKey));
                     }
                     if (!defined($attributeName)) {
                         throw new AgaviDatabaseException(sprintf('Unknown Attribute "%s"', $attributeName));
                     }
                 }
                 // resolve from constant if possible
                 if (strpos($attributeName, '::') && defined($attributeName)) {
                     $attributeName = constant($attributeName);
                 }
                 // resolve from constant if possible
                 if (strpos($attributeValue, '::') && defined($attributeValue)) {
                     $attributeValue = constant($attributeValue);
                 } elseif (ctype_digit($attributeValue)) {
                     $attributeValue = (int) $attributeValue;
                 }
                 $attributesDestination->setAttribute($attributeName, $attributeValue);
             }
         }
         foreach ((array) $this->getParameter('impls', array()) as $templateName => $className) {
             $this->connection->setImpl($templateName, $className);
         }
         foreach ((array) $this->getParameter('manager_impls', array()) as $templateName => $className) {
             $this->doctrineManager->setImpl($templateName, $className);
         }
         // load models (that'll just work with empty values too)
         Doctrine::loadModels($this->getParameter('load_models'));
         // for 1.2, handle model autoloading and base paths
         if ($is12 && ($this->hasParameter('load_models') || $this->hasParameter('models_directory'))) {
             if (!in_array(array('Doctrine', 'modelsAutoload'), $splAutoloadFunctions) && !in_array(array('Doctrine_Core', 'modelsAutoload'), $splAutoloadFunctions)) {
                 spl_autoload_register(array('Doctrine_Core', 'modelsAutoload'));
             }
             if ($this->hasParameter('models_directory')) {
                 Doctrine_Core::setModelsDirectory($this->getParameter('models_directory'));
             }
         }
         // for 1.2, handle extension autoloading, base paths and registration
         if ($is12 && ($this->hasParameter('extensions_path') || $this->hasParameter('register_extensions'))) {
             if (!in_array(array('Doctrine', 'extensionsAutoload'), $splAutoloadFunctions) && !in_array(array('Doctrine_Core', 'extensionsAutoload'), $splAutoloadFunctions)) {
                 spl_autoload_register(array('Doctrine_Core', 'extensionsAutoload'));
             }
//.........这里部分代码省略.........
开发者ID:philippjenni,项目名称:icinga-web,代码行数:101,代码来源:AgaviDoctrineDatabase.class.php

示例9:

<?php
// system/application/plugins/doctrine_pi.php

// load Doctrine library
require_once APPPATH . '/plugins/doctrine/lib/Doctrine.php';

// load database configuration from CodeIgniter
require_once APPPATH . '/config/database.php';

Doctrine_Core::setModelsDirectory(APPPATH . '/models');
// this will allow Doctrine to load Model classes automatically
spl_autoload_register(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
// we load our database connections into Doctrine_Manager
// this loop allows us to use multiple connections later on
foreach ($db as $connection_name => $db_values) {

    // first we must convert to dsn format
    $dsn = $db[$connection_name]['dbdriver'] . '://' . $db[$connection_name]['username'] .
        ':' . $db[$connection_name]['password'] . '@' . $db[$connection_name]['hostname'] .
        '/' . $db[$connection_name]['database'];

    Doctrine_Manager::connection($dsn, $connection_name);
}

// CodeIgniter's Model class needs to be loaded
require_once BASEPATH . '/libraries/Model.php';



// (OPTIONAL) CONFIGURATION BELOW
开发者ID:nahue,项目名称:LolaRestoBar,代码行数:31,代码来源:doctrine_pi.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


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