本文整理汇总了PHP中Doctrine\DBAL\Schema\AbstractSchemaManager::createSchemaConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractSchemaManager::createSchemaConfig方法的具体用法?PHP AbstractSchemaManager::createSchemaConfig怎么用?PHP AbstractSchemaManager::createSchemaConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\AbstractSchemaManager
的用法示例。
在下文中一共展示了AbstractSchemaManager::createSchemaConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTestTable
protected function getTestTable($name, $options=array())
{
$table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options);
$table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', array('notnull' => true));
$table->setPrimaryKey(array('id'));
$table->addColumn('test', 'string', array('length' => 255));
$table->addColumn('foreign_key_test', 'integer');
return $table;
}
示例2: getTestCompositeTable
protected function getTestCompositeTable($name)
{
$table = new Table($name, array(), array(), array(), false, array());
$table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', array('notnull' => true));
$table->addColumn('other_id', 'integer', array('notnull' => true));
$table->setPrimaryKey(array('id', 'other_id'));
$table->addColumn('test', 'string', array('length' => 255));
return $table;
}
示例3: executeChanges
/**
* Executes the changes.
*/
public function executeChanges()
{
$platform = $this->db->getDatabasePlatform();
if (!empty($this->dropTables)) {
foreach ($this->dropTables as $t) {
$this->sm->dropTable($this->prefix . $t);
}
}
$sql = $this->schema->toSql($platform);
if (!empty($sql)) {
foreach ($sql as $s) {
$this->db->executeUpdate($s);
}
}
//reset schema
$this->schema = new Schema([], [], $this->sm->createSchemaConfig());
$this->dropTables = $this->addTables = [];
}
示例4: getSchemaFromMetadata
/**
* Create schema instance from metadata
*
* @param array $metadata
* @return \Doctrine\DBAL\Schema\Schema
*/
public function getSchemaFromMetadata(array $metadata)
{
$entityMetadataSchemaConfig = $this->schemaManager->createSchemaConfig();
$schema = new Schema([], [], $entityMetadataSchemaConfig);
$pivotTables = [];
foreach ($metadata as $entityMetadata) {
$this->generateTableFromMetadata($schema, $entityMetadata['table']);
// create version table
if (!empty($entityMetadata['versionTable'])) {
$this->generateTableFromMetadata($schema, $entityMetadata['versionTable']);
}
foreach ($entityMetadata['relations'] as $relationMetadata) {
if (!empty($relationMetadata['pivotTable'])) {
// create pivot table for many to many relations
if (!in_array($relationMetadata['pivotTable']['name'], $pivotTables)) {
$this->generateTableFromMetadata($schema, $relationMetadata['pivotTable']);
}
$pivotTables[] = $relationMetadata['pivotTable']['name'];
}
}
}
return $schema;
}