本文整理汇总了PHP中Doctrine::generateModelsFromYaml方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine::generateModelsFromYaml方法的具体用法?PHP Doctrine::generateModelsFromYaml怎么用?PHP Doctrine::generateModelsFromYaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine
的用法示例。
在下文中一共展示了Doctrine::generateModelsFromYaml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: execute
public function execute()
{
Doctrine::generateModelsFromYaml($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'), $this->getArgument('generate_models_options', array()));
$this->notify('Generated models successfully from YAML schema');
}
示例3: realpath
* @author Dejan Spasic <spasic.dejan@yahoo.de>
* @version SVN: $Id: bootstrap.php 20057 2009-07-09 13:40:40Z Dejan.Spasic $
*/
// Autofind the first available app environment
$sfRootDir = realpath(dirname(__FILE__) . '/../../../');
$appsDir = glob($sfRootDir . '/apps/*', GLOB_ONLYDIR);
$app = substr($appsDir[0], strrpos($appsDir[0], DIRECTORY_SEPARATOR) + 1, strlen($appsDir[0]));
if (!$app) {
throw new Exception('No app has been detected in this project');
}
// -- path to the symfony project where the plugin resides
$sfPath = dirname(__FILE__) . '/../../..';
// bootstrap
include $sfPath . '/test/bootstrap/unit.php';
// initialize database manager
new sfDatabaseManager(ProjectConfiguration::getActive());
// initialize database connection for our tests
Doctrine_Manager::connection('sqlite::memory:', '_test_graphiz');
// clean the model directory
try {
$_fs = new sfFilesystem();
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/_files/model'), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $file) {
$_fs->remove($file->getPathname());
}
$_fs->remove(dirname(__FILE__) . '/_files/model');
} catch (Exception $e) {
}
// generate the model
Doctrine::generateModelsFromYaml(dirname(__FILE__) . '/_files', dirname(__FILE__) . '/_files/model');
示例4: doctrine_create_models
/**
* Generates Models from YAML Schema file
* @param string $name
*/
function doctrine_create_models($name = NULL)
{
if ($name === NULL) {
$location = SCHEMA_DIRECTORY;
} else {
$location = SCHEMA_DIRECTORY . $name;
}
Doctrine::generateModelsFromYaml($location, MODELS_DIRECTORY);
}
示例5: define
<?php
define("CLASSPATH", realpath(dirname(__FILE__) . "/../.."));
define("DOCTRINE_FOLDER", CLASSPATH . "/3rdParty/Doctrine-1.1.0/lib");
define("MODELS_FOLDER", CLASSPATH . "/models/data_objects");
define("YML_FOLDER", CLASSPATH . "/models/yml");
require_once DOCTRINE_FOLDER . '/Doctrine.php';
require_once CLASSPATH . '/config/db.conf.php';
spl_autoload_register(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
$conn = Doctrine_Manager::connection("{$db_conn_type}://{$db_user}:{$db_pass}@{$db_host}/{$db_name}", 'doctrine');
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
Doctrine::dropDatabases();
Doctrine::createDatabases();
Doctrine::generateModelsFromYaml(YML_FOLDER . '/db.yml', MODELS_FOLDER);
Doctrine::createTablesFromModels(MODELS_FOLDER);
示例6: dirname
<?php
/**
* Script for creating and loading database
*/
include_once dirname(__FILE__) . '/../../../application/bootstrap.php';
echo 'Generating models from schemas' . PHP_EOL;
try {
Doctrine::generateModelsFromYaml('user.yml', APPLICATION_PATH . '/models');
Doctrine::createTablesFromArray(array('User'));
} catch (Exception $e) {
echo 'AN ERROR HAS OCCURED:' . PHP_EOL;
echo $e->getMessage() . PHP_EOL;
return false;
}
// Generally speaking, this script will be run from the command line
return true;
示例7: _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 = sys_get_temp_dir() . DIRECTORY_SEPARATOR . strtolower($prefix) . '_doctrine_tmp_dirs';
$options = array('classPrefix' => $prefix);
if (is_string($item) && file_exists($item)) {
if (is_dir($item)) {
$files = glob($item . DIRECTORY_SEPARATOR . '*.*');
} else {
$files = array($item);
}
if (isset($files[0])) {
$pathInfo = pathinfo($files[0]);
$extension = $pathInfo['extension'];
}
if ($extension === 'yml') {
Doctrine::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::generateModelsFromDb($path, (array) $item, $options);
return $path;
} catch (Exception $e) {
throw new Doctrine_Migration_Exception('Could not generate models from connection: ' . $e->getMessage());
}
}
}
示例8:
$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
//Le digo a doctrine que realice todas las validaciones de integridad: valores nulos, constrains, etc.
$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
//Permito los override en las clases
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
if ($GLOBALS["BDLazyMode"]) {
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
} else {
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_AGGRESSIVE);
}
//Cargo todo el modelo
if (file_exists('../../model/generated')) {
Doctrine::loadModels('../../model/generated');
} else {
if ($GLOBALS["debugMode"]) {
echo "No se ha encontrador el directorio 'model/generated'";
}
}
if (file_exists('../../model')) {
Doctrine::loadModels('../../model');
} else {
if ($GLOBALS["debugMode"]) {
echo "No se ha encontrador el directorio 'model'";
}
}
//Debo hace un aggressive loadin de manera obligarotia, sino no se cargan todas las clases
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_AGGRESSIVE);
Doctrine::dropDatabases();
Doctrine::createDatabases();
Doctrine::generateModelsFromYaml('../../schema.yml', '../../model');
示例9:
<?php
require_once '../Plans.php';
Doctrine::generateModelsFromYaml('../db/schema.yaml', '../db/');