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


PHP ezcDbSchema::createFromDb方法代码示例

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


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

示例1: testUppercaseDataTypes

 public function testUppercaseDataTypes()
 {
     $path = dirname(__FILE__) . '/testfiles/bug13072.sqlite';
     $db = ezcDbFactory::create("sqlite://{$path}");
     $newSchema = ezcDbSchema::createFromDb($db);
     $schema = $newSchema->getSchema();
     self::assertEquals('integer', $schema['authors']->fields['id']->type);
     self::assertEquals('text', $schema['authors']->fields['firstname']->type);
     self::assertEquals('text', $schema['ownership']->fields['critique']->type);
 }
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:10,代码来源:sqlite_test.php

示例2: testUnsupportedMySQLDbField

    public function testUnsupportedMySQLDbField()
    {
        $sql = <<<ENDL
CREATE TABLE `testexternal_musiclists` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `external_id` varchar(256) NOT NULL,
  `url` varchar(256) default NULL,
  `title` varchar(256) NOT NULL,
  `description` text,
  `type` enum('iMix','iTunes') NOT NULL default 'iMix',
  `last_updated` datetime NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `external_id` (`external_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='';
ENDL;
        $this->db->query($sql);
        try {
            $schema = ezcDbSchema::createFromDb($this->db);
            self::fail("Expected exception not thrown.");
        } catch (ezcDbSchemaUnsupportedTypeException $e) {
            self::assertEquals("The field type 'enum' is not supported with the 'MySQL' handler.", $e->getMessage());
        }
    }
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:23,代码来源:mysql_test.php

示例3: __autoload

<?php

/**
 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 * @version 1.3.1
 * @filesource
 * @package WorkflowDatabaseTiein
 * @ignore
 */
require_once '../../../trunk/Base/src/base.php';
function __autoload($className)
{
    ezcBase::autoload($className);
}
$db = ezcDbFactory::create('mysql://test@localhost/test');
$schema = ezcDbSchema::createFromDb($db);
$schema->writeToFile('array', '../tests/workflow.dba');
file_put_contents('../tests/workflow.dba', str_replace('<?php return array (', '<?php
return array (', file_get_contents('../tests/workflow.dba')));
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:20,代码来源:create_schema.php

示例4: saveSchema

 /**
  * Saves the schema from database to file.
  *
  * Use this method if you have changed the definition of the persistent object
  * and need to update the file on disk.
  */
 public function saveSchema()
 {
     $db = ezcDbInstance::get();
     $schema = ezcDbSchema::createFromDb($db);
     $schema->writeToFile('array', dirname(__FILE__) . '/persistent_test_object.dba');
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:12,代码来源:native_generator_test.php

示例5: saveSchema

 /**
  * Saves the schema from database to file.
  *
  * Use this method if you have changed the definition of the persistent object
  * and need to update the file on disk.
  */
 public static function saveSchema()
 {
     $db = ezcDbInstance::get();
     $schema = ezcDbSchema::createFromDb($db);
     $schema->writeToFile('array', dirname(__FILE__) . '/table.dba');
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:12,代码来源:table_class.php

示例6: 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

示例7: testApply2

 public function testApply2()
 {
     $schema1 = self::getSchema3();
     $schema1->writeToDb($this->db);
     $schemaDiff = self::getSchemaDiff2();
     $schemaDiff->applyToDb($this->db);
     $schemaInDb = ezcDbSchema::createFromDb($this->db);
     $this->resetDb();
     $schema4 = self::getSchema4()->getSchema();
     $schemaInDb = $schemaInDb->getSchema();
     self::assertEquals($schema4['table'], $schemaInDb['table']);
     self::assertEquals($schema4['order'], $schemaInDb['order']);
     self::assertEquals($schema4['bugdb_change'], $schemaInDb['bugdb_change']);
 }
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:14,代码来源:generic_diff_test.php

示例8: 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

示例9: getSchema

 /**
  * Returns an {@link ezcDbSchema} created from $source which is of $format.
  * 
  * @param string $format 
  * @param string $source 
  * @return ezcDbSchema
  */
 private function getSchema($format, $source)
 {
     $readerClass = ezcDbSchemaHandlerManager::getReaderByFormat($format);
     $reader = new $readerClass();
     $schema = null;
     switch (true) {
         case $reader instanceof ezcDbSchemaDbReader:
             $db = ezcDbFactory::create($source);
             $schema = ezcDbSchema::createFromDb($db);
             break;
         case $reader instanceof ezcDbSchemaFileReader:
         default:
             $schema = ezcDbSchema::createFromFile($format, $source);
             break;
     }
     return $schema;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:24,代码来源:generator.php

示例10: testWriteWithoutPrefixReadWithPrefix

 public function testWriteWithoutPrefixReadWithPrefix()
 {
     $optionsWithoutPrefix = new ezcDbSchemaOptions();
     $optionsWithoutPrefix->tableNamePrefix = '';
     $optionsWithPrefix = new ezcDbSchemaOptions();
     $optionsWithPrefix->tableNamePrefix = 'prefix_';
     $schema = new ezcDbSchema(self::getSchema());
     $schemaWithPrefix = new ezcDbSchema(self::getSchemaWithPrefixedTableNames());
     ezcDbSchema::setOptions($optionsWithoutPrefix);
     $schemaWithPrefix->writeToDb($this->db);
     ezcDbSchema::setOptions($optionsWithPrefix);
     $newSchema = ezcDbSchema::createFromDb($this->db);
     self::assertEquals($schema, $newSchema);
 }
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:14,代码来源:generic_test.php

示例11: data

        'rgt' integer NOT NULL
    );
    CREATE UNIQUE INDEX 'nested_set_pri' on 'nested_set' ( 'id' );
    CREATE INDEX 'nested_set_left' on 'nested_set' ( 'lft' );
    CREATE INDEX 'nested_set_right' on 'nested_set' ( 'rgt' );

    CREATE TABLE data (
        'node_id' varchar(255) NOT NULL,
        'melting_temp_k' float,
        'boiling_temp_k' float
    );
    CREATE UNIQUE INDEX 'data_pri' on 'data' ( 'node_id' );
ENDSQL
);
// Create the example Persistent Object definition files and stub classes
$dbSchema = ezcDbSchema::createFromDb($dbh);
$writer1 = new ezcDbSchemaPersistentWriter(true);
$writer2 = new ezcDbSchemaPersistentClassWriter(true);
$writer1->saveToFile('files/po_defs', $dbSchema);
$writer2->saveToFile('files/classes', $dbSchema);
require 'files/classes/data.php';
// Setup the store and tree
$session = new ezcPersistentSession($dbh, new ezcPersistentCodeManager("files/po_defs"));
$store = new ezcTreePersistentObjectDataStore($session, 'data', 'node_id');
$tree = new ezcTreeDbNestedSet($dbh, 'nested_set', $store);
// Insert data
$metal = new data();
$tree->setRootNode($root = $tree->createNode('Metals', $metal));
$iron = new data();
$iron->setState(array('melting_temp_k' => 1811, 'boiling_temp_k' => 3134));
$root->addChild($tree->createNode('Fe', $iron));
开发者ID:bmdevel,项目名称:ezc,代码行数:31,代码来源:tutorial_example_persistent_object.php

示例12: __get

 public function __get($name)
 {
     switch ($name) {
         case 'poDef':
             if (is_null($this->_poDef)) {
                 $pos = ezcPersistentSessionInstance::get();
                 $this->_poDef = $pos->definitionManager->fetchDefinition($this->poClass);
             }
             return $this->_poDef;
         case 'schema':
             if (is_null($this->_schema)) {
                 $this->_schema = ezcDbSchema::createFromDb(ezcDbInstance::get());
             }
             return $this->_schema;
     }
     return parent::__get($name);
 }
开发者ID:jpic,项目名称:ezc-framework-apps,代码行数:17,代码来源:admin.php


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