本文整理汇总了PHP中Doctrine_Import_Schema::buildSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Import_Schema::buildSchema方法的具体用法?PHP Doctrine_Import_Schema::buildSchema怎么用?PHP Doctrine_Import_Schema::buildSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Import_Schema
的用法示例。
在下文中一共展示了Doctrine_Import_Schema::buildSchema方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTest
public function testTest()
{
$yml = <<<END
---
detect_relations: true
Ticket_1118_User:
columns:
username: string(255)
password: string(255)
ticket__1118__profile_id: string
Ticket_1118_Profile:
columns:
id:
type: integer(4)
autoincrement: true
primary: true
name: string(255)
END;
try {
file_put_contents('test.yml', $yml);
$import = new Doctrine_Import_Schema();
$array = $import->buildSchema('test.yml', 'yml');
// Test that ticket__1118__profile_id is changed to to be integer(4) since the primary key of
// the relationship is set to that
$this->assertEqual($array['Ticket_1118_User']['columns']['ticket__1118__profile_id']['type'], 'integer');
$this->assertEqual($array['Ticket_1118_User']['columns']['ticket__1118__profile_id']['length'], '4');
$this->pass();
} catch (Exception $e) {
$this->fail();
}
unlink('test.yml');
}
示例2: testTest
public function testTest()
{
$yml = <<<END
---
Ticket_1527_User:
columns:
username:
type: string(255)
extra:
test: 123
password:
type: string(255)
END;
$import = new Doctrine_Import_Schema();
$schema = $import->buildSchema($yml, 'yml');
$this->assertEqual($schema['Ticket_1527_User']['columns']['username']['extra']['test'], '123');
$path = dirname(__FILE__) . '/../tmp';
$import->importSchema($yml, 'yml', $path);
require_once($path . '/generated/BaseTicket_1527_User.php');
require_once($path . '/Ticket_1527_User.php');
$username = Doctrine::getTable('Ticket_1527_User')->getDefinitionOf('username');
$this->assertEqual($username['extra']['test'], '123');
}
示例3: testBuildSchema
public function testBuildSchema()
{
$schema = new Doctrine_Import_Schema();
$array = $schema->buildSchema('schema.yml', 'yml');
$model = $array['SchemaTestUser'];
$this->assertTrue(array_key_exists('connection', $model));
$this->assertTrue(array_key_exists('className', $model));
$this->assertTrue(array_key_exists('tableName', $model));
$this->assertTrue(array_key_exists('columns', $model) && is_array($model['columns']));
$this->assertTrue(array_key_exists('relations', $model) && is_array($model['relations']));
$this->assertTrue(array_key_exists('indexes', $model) && is_array($model['indexes']));
$this->assertTrue(array_key_exists('attributes', $model) && is_array($model['attributes']));
$this->assertTrue(array_key_exists('templates', $model) && is_array($model['columns']));
$this->assertTrue(array_key_exists('actAs', $model) && is_array($model['actAs']));
$this->assertTrue(array_key_exists('options', $model) && is_array($model['options']));
$this->assertTrue(array_key_exists('package', $model));
$this->assertTrue(array_key_exists('inheritance', $model) && is_array($model['inheritance']));
$this->assertTrue(array_key_exists('detect_relations', $model) && is_bool($model['detect_relations']));
$this->assertEqual($array['AliasTest']['columns']['test_col']['name'], 'test_col as test_col_alias');
}
示例4: testBuildSchema
public function testBuildSchema()
{
$import = new Doctrine_Import_Schema();
$array = $import->buildSchema('Ticket/1617_schema.yml', 'yml');
$this->assertEqual($array['term']['columns']['language']['name'], 'lang as language');
}
示例5: _importSchema
/**
* importSchema
*
* A method to import a Schema and translate it into a Doctrine_Record object
*
* @param string $schema The file containing the XML schema
* @param string $format Format of the schema file
* @param string $directory The directory where the Doctrine_Record class will be written
* @param array $models Optional array of models to import
*
* @return void
*/
protected function _importSchema($schema, $format = 'yml', $directory = null, $options = array())
{
$schema = (array) $schema;
$builder = new Install_Api_DoctrineBuilder();
$builder->setTargetPath($directory);
$builder->setOptions($options);
$importer = new Doctrine_Import_Schema();
$array = $importer->buildSchema($schema, $format);
if (count($array) == 0) {
throw new Doctrine_Import_Exception(sprintf('No ' . $format . ' schema found in ' . implode(", ", $schema)));
}
foreach ($array as $name => $definition) {
$builder->buildRecord($definition);
}
}