本文整理汇总了PHP中Doctrine::loadData方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine::loadData方法的具体用法?PHP Doctrine::loadData怎么用?PHP Doctrine::loadData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine
的用法示例。
在下文中一共展示了Doctrine::loadData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public function setup()
{
$db = $this->databasemanager->getDatabase('doctrine');
/* @var $db sfDoctrineDatabase */
// Special Handling for postgre, since droping even when closing the connection, fails with
// SQLSTATE[55006]: Object in use: 7 ERROR: database "cs_doctrine_act_as_sortable_test" is being accessed by other users DETAIL: There are 1 other session(s) using the database.
if ($db->getDoctrineConnection() instanceof Doctrine_Connection_Pgsql) {
try {
$db->getDoctrineConnection()->createDatabase();
} catch (Exception $e) {
}
$export = new Doctrine_Export_Pgsql($db->getDoctrineConnection());
$import = new Doctrine_Import_Pgsql($db->getDoctrineConnection());
$tablenames = array(SortableArticleTable::getInstance()->getTableName(), SortableArticleUniqueByTable::getInstance()->getTableName(), SortableArticleCategoryTable::getInstance()->getTableName());
foreach ($tablenames as $tablename) {
if ($import->tableExists($tablename)) {
$export->dropTable($tablename);
}
}
} else {
try {
// ignore error if database does not yet exist (clean CI-env)
$db->getDoctrineConnection()->dropDatabase();
} catch (Exception $e) {
}
$db->getDoctrineConnection()->createDatabase();
}
// Using Doctrine instead of Doctrine_Core keeps it symfony 1.2 compatible, which uses
Doctrine::loadModels(dirname(__FILE__) . '/../fixtures/project/lib/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE);
Doctrine::createTablesFromArray(Doctrine::getLoadedModels());
Doctrine::loadData(dirname(__FILE__) . '/../fixtures/project/data/fixtures/categories.yml');
}
示例2: loadData
public function loadData($configuration)
{
new sfDatabaseManager($configuration);
self::initiateDB($configuration);
Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures');
return $this;
}
示例3: testI18nExport
public function testI18nExport()
{
try {
$i = new I18nTestExport();
$i->Translation['en']->title = 'english test';
$i->Translation['fr']->title = 'french test';
$i->test_object = new stdClass();
$i->save();
$data = new Doctrine_Data();
$data->exportData('test.yml', 'yml', array('I18nTestExport', 'I18nTestExportTranslation'));
$array = Doctrine_Parser::load('test.yml', 'yml');
$this->assertTrue(!empty($array));
$this->assertTrue(isset($array['I18nTestExport']['I18nTestExport_1']));
$this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_en']));
$this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_fr']));
$i->Translation->delete();
$i->delete();
Doctrine::loadData('test.yml');
$q = Doctrine_Query::create()->from('I18nTestExport e')->leftJoin('e.Translation t');
$results = $q->execute();
$this->assertEqual(get_class($results[0]->test_object), 'stdClass');
$this->pass();
} catch (Exception $e) {
$this->fail($e->getMessage());
}
if (file_exists('test.yml')) {
unlink('test.yml');
}
}
示例4: loadData
/**
* DOCUMENT ME
* @param mixed $path
* @return mixed
*/
public function loadData($path = null)
{
if (!$path) {
$path = sfConfig::get('sf_test_dir') . '/fixtures';
}
Doctrine::loadData($path);
return $this;
}
示例5: run
public function run()
{
$path = $this->options['dir'] . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . $this->options['name'] . '.yml';
if (!file_exists($path)) {
throw new RuntimeException('The specified yml doesn\'t exist.');
}
Doctrine::loadData($path, true);
}
示例6: loadData
public function loadData($file = null)
{
$fixture = sfConfig::get('sf_test_dir') . '/fixtures';
if ($file !== null) {
$fixture .= "/{$file}";
}
Doctrine::loadData($fixture);
}
示例7: setUp
public function setUp()
{
parent::resetMongo();
sfConfig::set('sf_environment', 'test');
Doctrine::loadData(dirname(__FILE__) . '/fixtures');
sfConfig::set('sf_environment', 'dev');
$this->from = date('Y-m-d', strtotime("today"));
$this->to = date('Y-m-d', strtotime("tomorrow"));
}
示例8: testUpdateOwnedIdentities
public function testUpdateOwnedIdentities()
{
parent::resetMongo();
Doctrine::loadData(dirname(__FILE__) . '/fixtures');
$lUserHugo = UserTable::getByIdentifier('hugo');
$lUserHugo->updateOwnedIdentities(array("1", "2", "34"));
$lRelation = $lUserHugo->retrieveUserRelations();
$this->assertTrue(in_array("34", $lRelation->getOwnedOi()));
}
示例9: load_fixtures
function load_fixtures()
{
echo 'This will delete all existing data!<br />
<form action="" method="POST">
<input type="submit" name="action" value="Load Fixtures"><br /><br />';
if ($this->input->post('action')) {
Doctrine_Manager::connection()->execute('SET FOREIGN_KEY_CHECKS = 0');
Doctrine::loadData(APPPATH . '/fixtures');
echo "Done!";
}
}
示例10: loadData
public function loadData($file = null)
{
if ($this->connection == null) {
$this->connection = Doctrine_Manager::connection();
$this->connection->beginTransaction();
}
$fixture = sfConfig::get('sf_test_dir') . '/fixtures';
if ($file !== null) {
$fixture .= "/{$file}";
}
Doctrine::loadData($fixture);
}
示例11: 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);
}
}
示例12: testTest
public function testTest()
{
$yml = <<<END
Ticket_1351_Article:
Ticket_1351_Article_1:
Translation:
en:
title: Test title english
body: Test body english
fr:
title: Test title french
body: Test body french
END;
file_put_contents('test.yml', $yml);
Doctrine::loadData('test.yml', true);
unlink('test.yml');
$results = Doctrine_Query::create()->from('Ticket_1351_Article a, a.Translation t')->fetchArray();
$this->assertEqual($results[0]['Translation']['en']['title'], 'Test title english');
}
示例13: setUp
public function setUp()
{
//parent::resetMongo();
sfConfig::set('sf_environment', 'test');
Doctrine::loadData(dirname(__FILE__) . '/fixtures');
sfConfig::set('sf_environment', 'dev');
$this->table = Doctrine::getTable('Deal');
$this->deal1 = $this->table->findOneBy('name', 'Campaign No. 1');
$this->deal2 = $this->table->findOneBy('name', 'Campaign No. 2');
$this->deal3 = $this->table->findOneBy('name', 'Campaign No. 3');
$this->deal4 = $this->table->findOneBy('name', 'Campaign No. 4');
$this->deal5 = $this->table->findOneBy('name', 'Campaign No. 5');
$this->deal6 = $this->table->findOneBy('name', 'Campaign No. 6');
$this->deal7 = $this->table->findOneBy('name', 'Campaign No. 7');
$this->dealCommission1 = $this->table->findOneBy('name', 'Campaign No. Commission 1');
$this->dealCommission2 = $this->table->findOneBy('name', 'Campaign No. Commission 2');
$this->dealCommission3 = $this->table->findOneBy('name', 'Campaign No. Commission 3');
$this->hugo = UserTable::getInstance()->findOneByUsername('hugo');
$this->affe = UserTable::getInstance()->findOneByUsername('affe');
}
示例14: 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!";
}
}
示例15: 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());
}
}