本文整理汇总了PHP中Doctrine_Core::generateModelsFromYaml方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Core::generateModelsFromYaml方法的具体用法?PHP Doctrine_Core::generateModelsFromYaml怎么用?PHP Doctrine_Core::generateModelsFromYaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Core
的用法示例。
在下文中一共展示了Doctrine_Core::generateModelsFromYaml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_load_fixtures
function action_load_fixtures()
{
?>
This will delete all existing data!<br />
<form action="" method="POST">
<input type="submit" name="schema" value="Load Schema"><br /><br />
<?php
?>
This will delete all existing data!<br />
<form action="" method="POST">
<input type="submit" name="data" value="Load Fixtures"><br /><br />
<?php
if (!empty($_POST['schema'])) {
Doctrine_Core::generateModelsFromYaml(APPPATH . DIRECTORY_SEPARATOR . 'doctrine/fixtures/schema', APPPATH . DIRECTORY_SEPARATOR . 'doctrine/models', array('generateBaseClasses' => false));
echo "Done!";
} elseif (!empty($_POST['data'])) {
Doctrine_Manager::connection()->execute("\r\n\t\t\t\tSET FOREIGN_KEY_CHECKS = 0\r\n\t\t\t");
Doctrine::loadData(APPPATH . DIRECTORY_SEPARATOR . 'doctrine/fixtures/data');
echo "Done!";
}
}
示例2: _generateModels
/**
* Generate a set of models for the schema information source
*
* @param string $prefix Prefix to generate the models with
* @param mixed $item The item to generate the models from
* @return string $path The path where the models were generated
* @throws Doctrine_Migration_Exception $e
*/
protected function _generateModels($prefix, $item)
{
$path = $this->_tmpPath . DIRECTORY_SEPARATOR . strtolower($prefix) . '_doctrine_tmp_dirs';
$options = array('classPrefix' => $prefix, 'generateBaseClasses' => false);
if (is_string($item) && file_exists($item)) {
$extension = $this->_getItemExtension($item);
if ($extension === 'yml') {
Doctrine_Core::generateModelsFromYaml($item, $path, $options);
return $path;
} else {
if ($extension === 'php') {
Doctrine_Lib::copyDirectory($item, $path);
return $path;
} else {
throw new Doctrine_Migration_Exception('No php or yml files found at path: "' . $item . '"');
}
}
} else {
try {
Doctrine_Core::generateModelsFromDb($path, (array) $item, $options);
return $path;
} catch (Exception $e) {
throw new Doctrine_Migration_Exception('Could not generate models from connection: ' . $e->getMessage());
}
}
}
示例3: execute
public function execute()
{
Doctrine_Core::generateModelsFromYaml($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'), $this->getArgument('generate_models_options', array()));
$this->notify('Generated models successfully from YAML schema');
}
示例4: action_admin_yaml2models
/**
* yaml2models
*
* This generates MODELS from YAML schema files.
* This generates TABLES from MODELS.
*
* @see Doctrine_Core::generateModelsFromYaml
*/
public function action_admin_yaml2models()
{
// load sfYAML (it's somehow not loaded by doctrine autoload)
include ROOT_LIBRARIES . 'doctrine/Doctrine/Parser/sfYaml/SfYaml.php';
#Doctrine_Core::dropDatabases();
#Doctrine_Core::createDatabases();
Doctrine_Core::generateModelsFromYaml(DOCTRINE_YAML_SCHEMA_PATH . DIRECTORY_SEPARATOR . 'schema.yml', DOCTRINE_MODELS_PATH, self::$options);
#Doctrine_Core::createTablesFromModels( DOCTRINE_MODELS_PATH );
$message = '<b>The Models have been successfully generated from the YAML schema file.</b>';
$message .= '<br /><br />Destination Folder ' . DOCTRINE_MODELS_PATH;
#$message .= '<br /><br />The DATABASE TABLES have been successfully generated from MODELS.';
$this->setFlashmessage('success', $message);
$this->redirectToReferer();
}
示例5: defined
<?php
if (array_key_exists(1, $argv)) {
$env = $argv[1];
} else {
$env = 'production';
}
defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__) . '/..'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(BASE_PATH . '/library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$config = array('config' => array(realpath(BASE_PATH . '/configs/application.ini')));
$application = new Zend_Application($env, $config);
$dbConnection = $application->getBootstrap()->bootstrap('Doctrine');
try {
Doctrine_Core::dropDatabases();
} catch (Doctrine_Connection_Mysql_Exception $e) {
error_log('The database did not exists');
}
Doctrine_Core::createDatabases();
$options = $application->getOptions();
$ymlPath = realpath(BASE_PATH . '/Scripts/Yaml/Schema/Koryukan.yml');
$modelsOptions = array('suffix' => '.php', 'generateTableClasses' => true, 'classPrefix' => 'Koryukan_Db_', 'classPrefixFiles' => false, 'baseClassPrefix' => 'Base', 'baseClassesDirectory' => '');
Doctrine_Core::generateModelsFromYaml($ymlPath, $options['db']['objectsPath'], $modelsOptions);
Doctrine_Core::createTablesFromModels($options['db']['objectsPath']);
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/news.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/storeItems.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/images.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/security.yml');
示例6: define
<?php
/**
* Blog - Database Generator
*
* This file contains a script for generating the database for the blog demo.
* Running this script from command line as follows will generate a new database:
*
* <code>
* php generate.php
* </code>
*
* LICENSE
*
* This file is part of the Breeze Framework package and is subject to the new
* BSD license. For full copyright and license information, please see the
* LICENSE file that is distributed with this package.
*
* @author Jeff Welch <whatthejeff@gmail.com>
* @category Blog
* @package Databases
* @copyright Copyright (c) 2010, Breeze Framework
* @license New BSD License
* @version $Id$
*/
define('BREEZE_APPLICATION', realpath(dirname(__FILE__) . '/..'));
require_once BREEZE_APPLICATION . '/models/Doctrine.php';
Doctrine_Core::dropDatabases();
Doctrine_Core::createDatabases();
Doctrine_Core::generateModelsFromYaml(BREEZE_APPLICATION . '/databases/schema.yml', BREEZE_APPLICATION . '/models');
Doctrine_Core::createTablesFromModels(BREEZE_APPLICATION . '/models');
示例7: execute
public function execute()
{
$options = array('pearStyle' => true, 'generateTableClasses' => true, 'classPrefix' => 'Model_', 'baseClassPrefix' => 'Base_', 'baseClassesDirectory' => null, 'classPrefixFiles' => false, 'generateAccessors' => false);
Doctrine_Core::generateModelsFromYaml($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'), $this->getArgument('generate_models_options', $options));
$this->notify('Generated models successfully from YAML schema');
}
示例8: syncdb
public static function syncdb($apps = null, $drop_database = false, $append = true)
{
if (!self::$inited || !self::$connections) {
self::init();
}
if (!$apps) {
$apps = ini('base/INSTALLED_APPS');
}
if (!$apps) {
return true;
}
if ($drop_database) {
Doctrine_Core::dropDatabases();
Doctrine_Core::createDatabases();
}
foreach ((array) $apps as $k => $app) {
$app = str_replace('.', '/', $app);
try {
/*
* Generate the models
*/
if (isset($_GET['use_yaml'])) {
$schemas = Package::get_file(sprintf('applications/%s/%s', $app, 'schemas.yml'));
if (!is_file($schemas)) {
continue;
}
Doctrine_Core::generateModelsFromYaml($schemas, Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
} else {
try {
import(sprintf('applications/%s/models/generated/*', $app));
} catch (DoesNotExistsException $e) {
continue;
}
}
/*
* syncdb
*/
Doctrine_Core::createTablesFromModels(Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
/*
* Insert test data
*/
$dir = Package::get_folder(sprintf('applications/%s/fixtures', $app));
if (is_dir($dir)) {
Doctrine_Core::loadData($dir, $append);
}
} catch (PDOException $e) {
continue;
}
}
}
示例9: generateModels
public function generateModels()
{
Doctrine_Core::generateModelsFromYaml(MODELS . '/schema', MODELS, array('generateTableClasses' => true, 'baseClassesDirectory' => 'bases', 'baseClassName' => 'DefaultRecord', 'baseTableClassName' => 'DefaultTable'));
FlashComponent::set('info', 'Generate Models terminé.');
$this->redirect(array('action' => 'index'));
}