當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。