本文整理汇总了PHP中Doctrine::createTablesFromModels方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine::createTablesFromModels方法的具体用法?PHP Doctrine::createTablesFromModels怎么用?PHP Doctrine::createTablesFromModels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine
的用法示例。
在下文中一共展示了Doctrine::createTablesFromModels方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doctrine_create_database
/**
* Create Database Tables from Models
*/
function doctrine_create_database()
{
if (count(scandir(MODELS_DIRECTORY)) == 2) {
doctrine_create_models();
}
Doctrine::createTablesFromModels(MODELS_DIRECTORY);
}
示例2: createTables
protected function createTables()
{
try {
Doctrine::createTablesFromModels(array($this->modelPath));
} catch (Doctrine_Exception $e) {
echo "Error during schema creation - are you sure the table doesn't already exist? If so, use the update command.\n\n" . $e->getMessage();
}
}
示例3: create_tables
function create_tables()
{
echo 'Reminder: Make sure the tables do not exist already.<br />
<form action="" method="POST">
<input type="submit" name="action" value="Create Tables"><br /><br />';
if ($this->input->post('action')) {
Doctrine::createTablesFromModels();
echo "Done!";
}
}
示例4: main
/**
* Main entry point for task
*/
public function main()
{
$manager = Doctrine_Manager::getInstance();
// Set up validation
$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$conn = Doctrine_Manager::connection($this->_dsn->_toString());
$conn->setAttribute('portability', Doctrine::PORTABILITY_ALL);
$conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_AGGRESSIVE);
Doctrine::createTablesFromModels($this->_dir);
}
示例5: doctrineAction
public function doctrineAction()
{
$options = array('phpDocPackage' => 'Kromatick', 'phpDocSubpackage' => 'Intermodels', 'phpDocName' => 'Neozeratul', 'phpDocEmail' => 'neozeratul@gmail.com');
Doctrine::dropDatabases();
Doctrine::createDatabases();
Doctrine::generateModelsFromYaml(APPLICATION_PATH . "/data/schema/schema.yml", APPLICATION_PATH . "/models", $options);
Doctrine::createTablesFromModels();
//Doctrine::loadData($yamlPath, $append):
echo Doctrine::generateSqlFromModels();
$this->render('index');
}
示例6: setUp
public function setUp()
{
$manager = Doctrine_Manager::getInstance();
foreach ($manager as $conn) {
$modelsPath = APPLICATION_PATH . '/models';
$fixturesPath = APPLICATION_PATH . '/../doctrine/data/fixtures';
$name = array($conn->getName());
Doctrine::dropDatabases($name);
Doctrine::createDatabases($name);
Doctrine::createTablesFromModels($modelsPath);
Doctrine::loadData($fixturesPath, true);
}
}
示例7: setUp
public function setUp()
{
parent::setUp();
if (isset($GLOBALS['DOCTRINE_DSN']) && strlen($GLOBALS['DOCTRINE_DSN'])) {
Doctrine_Manager::connection($GLOBALS['DOCTRINE_DSN']);
} else {
Doctrine_Manager::connection('sqlite::memory:');
}
Doctrine::loadModels(dirname(__FILE__) . '/_files/models');
try {
Doctrine::createTablesFromModels();
} catch (Doctrine_Export_Exception $e) {
}
}
示例8: 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));
}
示例9: registerPlugin
public function registerPlugin(Bc_Application_Plugin_Descriptor $descriptor)
{
if ($this->isPluginRegistered($descriptor->getId())) {
return;
}
if (is_dir($descriptor->getModelsPath())) {
try {
Doctrine::createTablesFromModels($descriptor->getModelsPath());
} catch (Exception $e) {
var_dump($e);
}
}
$plugin = new Plugin();
$plugin->name = $descriptor->getId();
$plugin->description = $descriptor->getDescription();
$plugin->title = $descriptor->getName();
$plugin->active = true;
$plugin->save();
}
示例10: 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());
}
}
示例11: execute
protected function execute($arguments = array(), $options = array())
{
@$this->createCacheDirectory();
$oldPluginList = sfFinder::type('dir')->in(sfConfig::get('sf_plugins_dir'));
if (!$options['no-update-plugin']) {
$this->installPlugins();
}
$newPluginList = sfFinder::type('dir')->name('op*Plugin')->maxdepth(1)->in(sfConfig::get('sf_plugins_dir'));
$installedPlugins = array_map('basename', array_diff($newPluginList, $oldPluginList));
if (!$options['no-build-model']) {
$this->buildModel();
}
foreach ($installedPlugins as $v) {
$modelDir = sfConfig::get('sf_lib_dir') . '/model/doctrine/' . $v;
if (!is_dir($modelDir)) {
continue;
}
Doctrine::createTablesFromModels($modelDir);
}
$targets = array_merge(array('OpenPNE'), $this->getEnabledOpenPNEPlugin());
$databaseManager = new sfDatabaseManager($this->configuration);
foreach ($targets as $target) {
$params = array('version' => $options['to-version'], 'revision' => $options['to-revision']);
$this->migrateFromScript($target, $databaseManager, $params);
}
if ($options['execute-generate']) {
$this->migrateFromDiff();
}
$targets = array_merge($targets, $installedPlugins);
foreach ($targets as $target) {
$this->dataLoadForInitializePlugin($target);
}
if ($this->migrationException) {
throw $this->migrationException;
}
}
示例12: debug_backtrace
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// guess current application
if (!isset($app)) {
$traces = debug_backtrace();
$caller = $traces[0];
$dirPieces = explode(DIRECTORY_SEPARATOR, dirname($caller['file']));
$app = array_pop($dirPieces);
}
require_once dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true);
sfContext::createInstance($configuration);
// remove all cache
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
new sfDatabaseManager(sfContext::getInstance()->getConfiguration());
Doctrine::createTablesFromModels(dirname(__FILE__) . '/../../lib/model');
示例13: execute
public function execute()
{
Doctrine::createTablesFromModels($this->getArgument('models_path'));
$this->notify('Created tables successfully');
}
示例14:
<?php
require_once '../Plans.php';
Doctrine::createTablesFromModels();
示例15: testExportModelFromDirectory
public function testExportModelFromDirectory()
{
Doctrine::createTablesFromModels(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'export');
$this->assertEqual($this->adapter->pop(), 'COMMIT');
$this->assertEqual($this->adapter->pop(), 'ALTER TABLE cms__category_languages ADD CONSTRAINT cms__category_languages_category_id_cms__category_id FOREIGN KEY (category_id) REFERENCES cms__category(id) ON DELETE CASCADE');
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category_languages (id BIGINT AUTO_INCREMENT, name TEXT, category_id BIGINT, language_id BIGINT, INDEX index_category_idx (category_id), INDEX index_language_idx (language_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category (id BIGINT AUTO_INCREMENT, created DATETIME, parent BIGINT, position MEDIUMINT, active BIGINT, INDEX index_parent_idx (parent), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
}