當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ezcDbSchema::createFromFile方法代碼示例

本文整理匯總了PHP中ezcDbSchema::createFromFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP ezcDbSchema::createFromFile方法的具體用法?PHP ezcDbSchema::createFromFile怎麽用?PHP ezcDbSchema::createFromFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ezcDbSchema的用法示例。


在下文中一共展示了ezcDbSchema::createFromFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setupTable

 /**
  * Loads the schema from file into the database.
  */
 public static function setupTable()
 {
     $db = ezcDbInstance::get();
     // Load schema
     $schema = ezcDbSchema::createFromFile('array', dirname(__FILE__) . '/table.dba');
     $schema->writeToDb($db);
 }
開發者ID:bmdevel,項目名稱:ezc,代碼行數:10,代碼來源:table_class.php

示例2: testPhpArray

 public function testPhpArray()
 {
     $fileName = $this->tempDir . '/php_array_write_result.php';
     $schema = new ezcDbSchema(self::getSchema());
     $schema->writeToFile('array', $fileName);
     $newSchema = ezcDbSchema::createFromFile('array', $fileName);
     self::assertEquals($schema, $newSchema);
 }
開發者ID:jacomyma,項目名稱:GEXF-Atlas,代碼行數:8,代碼來源:php_array_test.php

示例3: getEmptyDb

 protected function getEmptyDb()
 {
     $schema = ezcDbSchema::createFromFile('xml', TESTPATH . '../src/schema.xml');
     //        $db = ezcDbFactory::create("sqlite://:memory:");
     $db = ezcDbFactory::create("sqlite:///home/ymc-toko/sqlite");
     $schema->writeToDb($db);
     return $db;
 }
開發者ID:jou,項目名稱:ymc-components,代碼行數:8,代碼來源:definition_storage_database.php

示例4: setUp

 protected function setUp()
 {
     $this->xmlSchema = ezcDbSchema::createFromFile('xml', dirname(__FILE__) . '/testfiles/bug8900.xml');
     // get the tables schema from the database schema
     // BY REFERENCE! - otherwise new/deleted tables are NOT updated
     // in the schema
     $this->schema =& $this->xmlSchema->getSchema();
 }
開發者ID:bmdevel,項目名稱:ezc,代碼行數:8,代碼來源:schema_test.php

示例5: testCreateFromFileNonExisting

 public function testCreateFromFileNonExisting()
 {
     try {
         ezcDbSchema::createFromFile('xml', 'testfiles/isnt-here.php');
         self::fail("Expected exception not thrown");
     } catch (Exception $e) {
         self::assertEquals("The schema file 'testfiles/isnt-here.php' could not be found.", $e->getMessage());
     }
 }
開發者ID:bmdevel,項目名稱:ezc,代碼行數:9,代碼來源:xml_diff_test.php

示例6: testParsingTrueFalse

 public function testParsingTrueFalse()
 {
     $fileName = realpath($this->testFilesDir . 'bug10365.xml');
     $schema = ezcDbSchema::createFromFile('xml', $fileName)->getSchema();
     self::assertEquals($schema['bug10365']->fields['field_notnull']->notNull, true);
     self::assertEquals($schema['bug10365']->fields['field_notnull']->autoIncrement, true);
     self::assertEquals($schema['bug10365']->fields['field_notnull']->unsigned, true);
     self::assertEquals($schema['bug10365']->fields['field_null']->notNull, false);
     self::assertEquals($schema['bug10365']->fields['field_null']->autoIncrement, false);
     self::assertEquals($schema['bug10365']->fields['field_null']->unsigned, false);
 }
開發者ID:bmdevel,項目名稱:ezc,代碼行數:11,代碼來源:xml_test.php

示例7: setupTable

 /**
  * Loads the schema from file into the database.
  */
 public static function setupTable()
 {
     $db = ezcDbInstance::get();
     // Load schema
     $schema = ezcDbSchema::createFromFile('array', dirname(__FILE__) . '/persistent_test_object.dba');
     $schema->writeToDb($db);
     // create sequence if it is a postgres database
     if ($db->getName() == 'pgsql') {
         $db->exec('CREATE SEQUENCE PO_test_seq START 5');
     }
 }
開發者ID:bmdevel,項目名稱:ezc,代碼行數:14,代碼來源:native_generator_test.php

示例8: setUp

 public function setUp()
 {
     $_GET = null;
     $_SERVER = self::$server;
     try {
         $this->db = ezcDbInstance::get();
         $schema = ezcDbSchema::createFromFile('array', dirname(__FILE__) . '/../../../docs/tutorial/openid_db_store_schema.dba');
         $schema->writeToDb($this->db);
     } catch (Exception $e) {
         $this->markTestSkipped("You must provide a database to runtests.php: " . $e->getMessage());
     }
 }
開發者ID:bmdevel,項目名稱:ezc,代碼行數:12,代碼來源:openid_db_store_test.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     try {
         $this->db = ezcDbInstance::get();
         $this->cleanupTables($this->db);
         $schema = ezcDbSchema::createFromFile('array', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'workflow.dba');
         $schema->writeToDb($this->db);
         $this->dbStorage = new ezcWorkflowDatabaseDefinitionStorage($this->db);
     } catch (Exception $e) {
         $this->markTestSkipped('No test database has been configured: ' . $e->getMessage());
     }
 }
開發者ID:jacomyma,項目名稱:GEXF-Atlas,代碼行數:13,代碼來源:case.php

示例10: setUp

 protected function setUp()
 {
     $tables = array('user', 'cache_templates', 'cache_values');
     // Get the DB instance
     try {
         $db = ezcDbInstance::get();
     } catch (Exception $e) {
         $this->markTestSkipped('No database handler defined');
     }
     $this->basePath = realpath(dirname(__FILE__)) . '/';
     // Setup the template engine
     $config = ezcTemplateConfiguration::getInstance();
     $this->tempDir = $config->compilePath = $this->createTempDir("ezcTemplate_");
     $config->templatePath = $this->basePath . 'templates/';
     $config->disableCache = false;
     $config->cacheManager = new DbCacheManager();
     // Create tables.
     foreach ($tables as $table) {
         try {
             $db->exec("DROP TABLE {$table}");
         } catch (Exception $e) {
         }
         // eat
     }
     $schema = ezcDbSchema::createFromFile('xml', dirname(__FILE__) . '/cache-manager-schema.xml');
     $schema->writeToDb($db);
     // insert some data
     $iq = $db->createInsertQuery();
     $s = $iq->insertInto($db->quoteIdentifier('user'))->set($db->quoteIdentifier('id'), 1)->set($db->quoteIdentifier('name'), $iq->bindValue('Raymond'))->set($db->quoteIdentifier('nickname'), $iq->bindValue('sunRay'))->prepare();
     $s->execute();
     $iq = $db->createInsertQuery();
     $s = $iq->insertInto($db->quoteIdentifier('user'))->set($db->quoteIdentifier('id'), 2)->set($db->quoteIdentifier('name'), $iq->bindValue('Derick'))->set($db->quoteIdentifier('nickname'), $iq->bindValue('Tiger'))->prepare();
     $s->execute();
     $iq = $db->createInsertQuery();
     $s = $iq->insertInto($db->quoteIdentifier('user'))->set($db->quoteIdentifier('id'), 3)->set($db->quoteIdentifier('name'), $iq->bindValue('Jan'))->set($db->quoteIdentifier('nickname'), $iq->bindValue('Amos'))->prepare();
     $s->execute();
 }
開發者ID:zetacomponents,項目名稱:template,代碼行數:37,代碼來源:cache_manager_test.php

示例11: getSchema

 /**
  * Returns the schema reader instance for the given schema path and format. 
  * 
  * @return object The schema reader.
  */
 protected function getSchema()
 {
     $schema = null;
     $readerClass = ezcDbSchemaHandlerManager::getReaderByFormat($this->schemaFormat);
     $reader = new $readerClass();
     switch (true) {
         case $reader instanceof ezcDbSchemaDbReader:
             $db = ezcDbFactory::create($this->pathSchema);
             $schema = ezcDbSchema::createFromDb($db);
             break;
         case $reader instanceof ezcDbSchemaFileReader:
             $schema = ezcDbSchema::createFromFile($this->schemaFormat, $this->pathSchema);
             break;
         default:
             $this->raiseError("Reader class not supported: '{$readerClass}'.");
             break;
     }
     return $schema;
 }
開發者ID:jpic,項目名稱:ezc-framework-apps,代碼行數:24,代碼來源:tool.php

示例12: testValidFromDb

 public function testValidFromDb()
 {
     $type = ezcTestSettings::getInstance()->db->phptype;
     $dsn = ezcTestSettings::getInstance()->db->dsn;
     if ($dsn === null || $type === null || $dsn === "sqlite://:memory:") {
         $this->markTestSkipped("DSN or database type not set or DSN not supported.");
     }
     // setup this test
     $destination = $this->createTempDir("PersObjDatSchem");
     $db = ezcDbFactory::create($dsn);
     $fileSource = dirname(__FILE__) . "/data/webbuilder.schema.xml";
     $schema = ezcDbSchema::createFromFile("xml", $fileSource);
     $schema->writeToDb($db);
     // real test
     $res = `php PersistentObjectDatabaseSchemaTiein/src/rungenerator.php -f "{$type}" -s "{$dsn}" "{$destination}"`;
     $this->assertEquals(1, preg_match('(PersistentObject\\sdefinition\\ssuccessfully\\swritten\\sto)s', $res), 'No success message found in generated output.');
     foreach (glob(dirname(__FILE__) . "/data/definition_only/definitions/*.php") as $file) {
         $this->assertEquals(file_get_contents($file), file_get_contents($destination . "/" . basename($file)), "Geneator generated an invalid persistent object definition file.");
     }
     $this->removeTempDir();
 }
開發者ID:jacomyma,項目名稱:GEXF-Atlas,代碼行數:21,代碼來源:test.php

示例13: run

 /**
  * Run the generator.
  * Process the given options and generate a PersistentObject definition from it.
  * 
  * @return void
  */
 public function run()
 {
     try {
         $this->input->process();
     } catch (ezcConsoleException $e) {
         $this->raiseError("Error while processing your options: {$e->getMessage()}", true);
     }
     if ($this->input->getOption('h')->value === true) {
         $this->output->outputText($this->input->getHelpText(ezcPersistentObjectSchemaGenerator::PROGRAM_DESCRIPTION, 80, true), "help");
         exit(0);
     }
     $defDir = $this->input->argumentDefinition["def dir"]->value;
     $classDir = $this->input->argumentDefinition["class dir"]->value;
     $schema = null;
     try {
         $readerClass = ezcDbSchemaHandlerManager::getReaderByFormat($this->input->getOption("format")->value);
         $reader = new $readerClass();
         switch (true) {
             case $reader instanceof ezcDbSchemaDbReader:
                 $db = ezcDbFactory::create($this->input->getOption("source")->value);
                 $schema = ezcDbSchema::createFromDb($db);
                 break;
             case $reader instanceof ezcDbSchemaFileReader:
                 $schema = ezcDbSchema::createFromFile($this->input->getOption("format")->value, $this->input->getOption("source")->value);
                 break;
             default:
                 $this->raiseError("Reader class not supported: '{$readerClass}'.");
                 break;
         }
     } catch (Exception $e) {
         $this->raiseError("Error reading schema: {$e->getMessage()}");
     }
     try {
         $writer = new ezcDbSchemaPersistentWriter($this->input->getOption("overwrite")->value, $this->input->getOption("prefix")->value);
         $writer->saveToFile($defDir, $schema);
         if ($classDir !== null) {
             $writer = new ezcDbSchemaPersistentClassWriter($this->input->getOption("overwrite")->value, $this->input->getOption("prefix")->value);
             $writer->saveToFile($classDir, $schema);
         }
     } catch (ezcBaseException $e) {
         $this->raiseError("Error writing schema: {$e->getMessage()}");
     }
     $this->output->outputLine("PersistentObject definition successfully written to {$defDir}.", 'info');
     if ($classDir !== null) {
         $this->output->outputLine("Class files successfully written to {$classDir}.", 'info');
     }
 }
開發者ID:jacomyma,項目名稱:GEXF-Atlas,代碼行數:53,代碼來源:generator.php

示例14: setUpTables

 protected function setUpTables()
 {
     $schema = ezcDbSchema::createFromFile('xml', dirname(__FILE__) . '/data/schema.xml');
     $schema->writeToDb($this->db);
 }
開發者ID:bmdevel,項目名稱:ezc,代碼行數:5,代碼來源:base.php

示例15: ezcDbSchemaTable

<?php

require 'tutorial_autoload.php';
// create a database schema from an XML file
$xmlSchema = ezcDbSchema::createFromFile('xml', 'enterprise.xml');
// get the tables schema from the database schema
// BY REFERENCE! - otherwise new/deleted tables are NOT updated in the schema
$schema =& $xmlSchema->getSchema();
// add a new table (employees) to the database
$schema['employees'] = new ezcDbSchemaTable(array('id' => new ezcDbSchemaField('integer', false, true, null, true)), array('primary' => new ezcDbSchemaIndex(array('id' => new ezcDbSchemaIndexField()), true)));
// copy the schema of table employees to table persons
$schema['persons'] = clone $schema['employees'];
// delete the table table2
unset($schema['table2']);
// add the fields birthday and salary to the table employees
$schema['employees']->fields['birthday'] = new ezcDbSchemaField('date');
$schema['employees']->fields['salary'] = new ezcDbSchemaField('integer');
// modify the type of salary field to be float
$schema['employees']->fields['salary']->type = 'float';
// delete the field salary
unset($schema['employees']->fields['salary']);
開發者ID:bmdevel,項目名稱:ezc,代碼行數:21,代碼來源:tutorial_example_05.php


注:本文中的ezcDbSchema::createFromFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。