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


PHP Doctrine_Core::loadData方法代码示例

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


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

示例1: 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_Core::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');
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:29,代码来源:ExportTestCase.php

示例2: loadData

 /**
  * Set up the functional test to use a database (doctrine)
  * Loads test Data for functional tests - model database and sets up a dummy user
  *
  * @return object the context
  */
 public function loadData()
 {
     exec(dirname(__FILE__) . '/../../symfony doctrine:build --all --and-load --env=test --no-confirmation');
     exec(dirname(__FILE__) . '/../../symfony guard:create-user apptest abc123 --env=test');
     Doctrine_Core::loadData(sfConfig::get('sf_test_dir') . '/fixtures/50_FunctionalAll/table.yml', true);
     exec(dirname(__FILE__) . '/../../symfony cc --env=test');
     return $this;
 }
开发者ID:Alenpiera,项目名称:streeme,代码行数:14,代码来源:DoctrineTestFunctional.class.php

示例3: testInlineMultiple

    public function testInlineMultiple()
    {
        $yml = <<<END
---
DC147_Multiple:
  ISBN2:
    name: isbn2
  ISBN3:
    name: isbn3
DC147_Product: 
  Product_1: 
    name: book3
    MultipleValues:
      Multi_1:
        value: 123345678
        Multiple: ISBN2
      Multi_2:
        value: 232323233
        Multiple: ISBN3
  Product_2: 
    name: book4
    MultipleValues:
      Multi_3:
        value: 444455555
        Multiple: ISBN2
      Multi_4:
        value: 232323233
        Multiple: ISBN3
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $this->conn->clear();
            $query = new Doctrine_Query();
            $query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book3');
            $product = $query->fetchOne();
            $this->assertEqual($product->name, 'book3');
            $this->assertEqual($product->MultipleValues->count(), 2);
            $this->assertEqual($product->MultipleValues[0]->value, '123345678');
            $this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
            $this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
            $query = new Doctrine_Query();
            $query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book4');
            $product = $query->fetchOne();
            $this->assertEqual($product->name, 'book4');
            $this->assertEqual($product->MultipleValues->count(), 2);
            $this->assertEqual($product->MultipleValues[0]->value, '444455555');
            $this->assertEqual($product->MultipleValues[1]->value, '232323233');
            $this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
            $this->assertEqual(is_object($product->MultipleValues[1]->Multiple), true);
            $this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
            $this->assertEqual($product->MultipleValues[1]->Multiple->name, 'isbn3');
            $this->pass();
        } catch (Exception $e) {
            $this->fail();
        }
        unlink('test.yml');
    }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:58,代码来源:DC147TestCase.php

示例4: doctrine_populate_database

/**
 * Populate database with YAML fixtures
 * @param string $name
 */
function doctrine_populate_database($name = NULL)
{
    if ($name === NULL) {
        $location = FIXTURES_DIRECTORY;
    } else {
        $location = FIXTURES_DIRECTORY . $name . '.yml';
    }
    Doctrine_Core::loadData($location);
}
开发者ID:silentworks,项目名称:codeigniter_doctrine,代码行数:13,代码来源:doctrine_pi.php

示例5: testTest

    public function testTest()
    {
        $yml = <<<END
---
Ticket_DC23_BlogPost:
  BlogPost_1:
    Translation:
      en:
        title: Test
        body: Testing

Ticket_DC23_User: 
  User_1: 
    name: jwage
    Contact:
      name: Test Contact
      Address: Address_1
      Phonenumbers:
        Phonenumber_1:
          name: test1
        Phonenumber_2:
          name: test2
  User_2:
    name: romanb
    Contact:
      name: Roman
      Address:
        name: Testing
      Phonenumbers: [Phonenumber_3]

Ticket_DC23_Phonenumber:
  Phonenumber_3:
    name: Testing

Ticket_DC23_Address:
  Address_1:
    name: Test Address
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $q = Doctrine_Query::create()->from('Ticket_DC23_User u')->leftJoin('u.Contact c')->leftJoin('c.Phonenumbers p')->leftJoin('c.Address a');
            $results = $q->fetchArray();
            $this->assertTrue(isset($results[0]['Contact']['address_id']));
            $this->assertEqual(count($results[0]['Contact']['Phonenumbers']), 2);
            $this->assertEqual(count($results[1]['Contact']['Phonenumbers']), 1);
            $q = Doctrine_Query::create()->from('Ticket_DC23_BlogPost p')->leftJoin('p.Translation t');
            $results = $q->fetchArray();
            $this->assertEqual(count($results[0]['Translation']), 1);
            $this->pass();
        } catch (Exception $e) {
            echo $e->getTraceAsString();
            $this->fail($e->getMessage());
        }
        unlink('test.yml');
    }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:56,代码来源:DC23TestCase.php

示例6: testLoadData

 /**
  * Проверим что полученный yaml загружается в БД
  * @see Doctrine_Core::loadData()
  */
 public function testLoadData()
 {
     $csvImport = new myImportCsvVkoshelke($this->_csvData);
     $success = $csvImport->execute($this->_user);
     $this->assertTrue($success, 'Импорт должен завершиться успешно');
     file_put_contents($this->_ymlFileName, $csvImport->getYmlData());
     Doctrine_Core::loadData($this->_ymlFileName, true);
     $transfer = Doctrine::getTable('Operation')->findOneByTransferAmount('300000.00', Doctrine::HYDRATE_ARRAY);
     $this->assertNotEmpty($transfer, 'Перевод должен попасть в БД');
     $this->assertEquals(Operation::TYPE_TRANSFER, $transfer['type'], 'Тип операции перевода должен быть ' . Operation::TYPE_TRANSFER);
     $this->assertEquals('2010-06-06', $transfer['date'], 'Дата операции должна совпадать с датой в CSV');
 }
开发者ID:ru-easyfinance,项目名称:EasyFinance,代码行数:16,代码来源:myImportCsvVkoshelkeTest.php

示例7: 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_Core::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');
    }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:19,代码来源:1351TestCase.php

示例8: dirname

<?php

// test/unit/model/doctrine/RepositoryTableTest.php
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
// test環境でDB初期化
$configuration = ProjectConfiguration::getApplicationConfiguration('taskapp', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(dirname(__FILE__) . '/RepositoryFixture.yml');
$t = new lime_test(4);
// getInstance
$t->ok(($table = RepositoryTable::getInstance()) instanceof RepositoryTable, 'RepositoryTableインスタンス取得');
// レコード取得
$t->diag('findAll()');
$list = $table->findAll();
$t->is(count($list), 2, 'レコード全件取得');
// レコード取得
$t->diag('findOne***()');
$commit = $table->findOneByName('testrepo2');
$t->ok($commit instanceof Repository, 'レコードの取得成功');
$t->is($commit->getRepository(), 'git://github.com/hidenorigoto/test2.git', '取得したレコードのデータが正常');
开发者ID:hidenorigoto,项目名称:sfjp-cms2,代码行数:20,代码来源:RepositoryTableTest.php

示例9: defined

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');
开发者ID:EricHogue,项目名称:Koryukan,代码行数:29,代码来源:generateDB.php

示例10: dirname

 * This file is part of the lyMediaManagerPlugin package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * Functional tests for file system errors.
 *
 * @package     lyMediaManagerPlugin
 * @subpackage  functional tests
 * @copyright   Copyright (C) 2010 Massimo Giagnoni.
 * @license     http://www.symfony-project.org/license MIT
 * @version     SVN: $Id$
 */
include dirname(__FILE__) . '/../bootstrap/functional.php';
Doctrine_Core::loadData(dirname(__FILE__) . '/../data/fixtures/fixtures_fs.yml');
$root = Doctrine::getTable('lyMediaFolder')->findOneByName('media');
$subf1 = lyMediaFolderTable::getInstance()->findOneByName('testsub1');
$subf2 = lyMediaFolderTable::getInstance()->findOneByName('testsub2');
//Creates some test assets. Cannot be done in fixtures
$file = dirname(__FILE__) . '/../data/assets/asset1.png';
$asset = new lyMediaAsset();
$asset->setFolder($subf1);
$asset->setFilename($file);
$asset->save();
$asset->refresh();
$file = dirname(__FILE__) . '/../data/assets/asseta.png';
$asset2 = new lyMediaAsset();
$asset2->setFolder($subf2);
$asset2->setFilename($file);
$asset2->save();
开发者ID:vjousse,项目名称:lyMediaManagerPlugin,代码行数:31,代码来源:lyMediaManagerActionsFSTest.php

示例11: dirname

<?php

// test/unit/model/doctrine/PageTableTest.php
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
// test環境でDB初期化
$configuration = ProjectConfiguration::getApplicationConfiguration('taskapp', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(dirname(__FILE__) . '/PageFixture.yml');
$t = new lime_test(60);
// getInstance
$t->diag('getInstance()');
$table = PageTable::getInstance();
$t->ok($table instanceof PageTable, 'テーブルインスタンス取得');
// レコード取得
$t->diag('findAll()');
$list = $table->findAll();
$t->is(count($list), 4, 'レコード全件取得');
// レコード取得
$t->diag('findOne***()');
$page = $table->findOneByPath('/foo/bar');
$t->ok($page instanceof Page, 'レコードの取得成功');
$t->is($page->getTitle(), 'testtitle', '取得したレコードのデータが正常');
// getFromPath
$t->diag('getFromPath()');
$page = PageTable::getFromPath('/foo/bar');
$t->is($page->getTitle(), 'testtitle', '取得したレコードのデータが正常');
$t->is($page->getRepository()->getName(), 'testrepo', 'リレーション先も正しく取得');
// getListFromPath()
$t->diag('getListFromPath()');
$page_rec = PageTable::getListFromPath('/foo/');
// 最終更新日時を更新しておく。
开发者ID:hidenorigoto,项目名称:sfjp-cms2,代码行数:31,代码来源:PageTableTest.php

示例12: up

 public function up()
 {
     Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/restore.yml', true);
 }
开发者ID:sensorsix,项目名称:app,代码行数:4,代码来源:67_restore_deleted_role_migration.php

示例13: loadSampleData

 /**
  * loads the test data. 
  * This is executed only if the user has set this option during installation.
  *
  * @return void
  **/
 private function loadSampleData()
 {
     if (PropertyTable::get('sample_data_load')) {
         Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/fixtures/test', false);
         CommonTable::calculateTotals(true);
         $i18n = $this->getContext()->getI18N();
         $this->getUser()->info($i18n->__("Sample data has been loaded."));
         PropertyTable::set('sample_data_load', 0);
     }
 }
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:16,代码来源:actions.class.php

示例14: dirname

<?php

// test/bootstrap/Doctrine.php
include dirname(__FILE__) . '/unit.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(sfConfig::get('sf_test_dir') . '/fixtures');
开发者ID:AinhoaLM,项目名称:jobeet,代码行数:7,代码来源:Doctrine.php

示例15: testI18nImportWithInteger

    public function testI18nImportWithInteger()
    {
        $yml = <<<END
---
I18nNumberLang:
  I18nNumberLang_1:
    name: test
    Translation:
      0:
        title: english title
        body: english body
      1:
        title: french title
        body: french body
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $this->conn->clear();
            $query = new Doctrine_Query();
            $query->from('I18nNumberLang i, i.Translation t');
            $i = $query->execute()->getFirst();
            $this->assertEqual($i->name, 'test');
            $this->assertEqual($i->Translation['0']->title, 'english title');
            $this->assertEqual($i->Translation['1']->title, 'french title');
            $this->assertEqual($i->Translation['0']->body, 'english body');
            $this->assertEqual($i->Translation['1']->body, 'french body');
            $this->pass();
        } catch (Exception $e) {
            $this->fail($e->getMessage());
        }
        unlink('test.yml');
    }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:33,代码来源:ImportTestCase.php


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