本文整理汇总了PHP中Doctrine\DBAL\Schema\AbstractSchemaManager类的典型用法代码示例。如果您正苦于以下问题:PHP AbstractSchemaManager类的具体用法?PHP AbstractSchemaManager怎么用?PHP AbstractSchemaManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractSchemaManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(\Doctrine\DBAL\Schema\AbstractSchemaManager $schema_manager)
{
$this->schema_manager = $schema_manager;
foreach ($schema_manager->listTables() as $table) {
$this->tables[$table->getName()] = new TableInformation($this, $table);
}
foreach ($this->tables as $table) {
$this->findRelationships($table);
}
}
示例2: generate
/**
* Create array of all the fields for a table
*
* @param string $table Table Name
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @param string $database
*
* @return array|bool
*/
public function generate($table, $schema, $database)
{
$this->database = $database;
$columns = $schema->listTableColumns($table);
if (empty($columns)) {
return false;
}
$indexParser = new IndexParser($table, $schema);
$fields = $this->setEnum($this->getFields($columns, $indexParser), $table);
$indexes = $this->getMultiFieldIndexes($indexParser);
return array_merge($fields, $indexes);
}
示例3: generate
/**
* Create array of all the fields for a table
*
* @param string $table Table Name
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @param string $database
* @param bool $ignoreIndexNames
*
* @return array
*/
public function generate($table, $schema, $database, $ignoreIndexNames)
{
$this->database = $database;
$columns = $schema->listTableColumns($table);
if (empty($columns)) {
return [];
}
$indexGenerator = new IndexGenerator($table, $schema, $ignoreIndexNames);
$fields = $this->setEnum($this->getFields($columns, $indexGenerator), $table);
$fields = $this->getMultiFieldIndexes($fields, $indexGenerator);
return $fields;
}
示例4: saveSchemaToFile
/**
* @param $file
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
* @return bool
*/
public static function saveSchemaToFile($file, $sm)
{
$xml = new SimpleXMLElement('<database/>');
$xml->addChild('name', OC_Config::getValue("dbname", "owncloud"));
$xml->addChild('create', 'true');
$xml->addChild('overwrite', 'false');
$xml->addChild('charset', 'utf8');
foreach ($sm->listTables() as $table) {
self::saveTable($table, $xml->addChild('table'));
}
file_put_contents($file, $xml->asXML());
return true;
}
示例5: generate
/**
* Get array of foreign keys
*
* @param string $table Table Name
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
*
* @return array
*/
public function generate($table, $schema)
{
$this->table = $table;
$fields = [];
$foreignKeys = $schema->listTableForeignKeys($table);
if (empty($foreignKeys)) {
return array();
}
foreach ($foreignKeys as $foreignKey) {
$fields[] = ['name' => $this->getName($foreignKey), 'field' => $foreignKey->getLocalColumns()[0], 'references' => $foreignKey->getForeignColumns()[0], 'on' => $foreignKey->getForeignTableName(), 'onUpdate' => $foreignKey->hasOption('onUpdate') ? $foreignKey->getOption('onUpdate') : 'RESTRICT', 'onDelete' => $foreignKey->hasOption('onDelete') ? $foreignKey->getOption('onDelete') : 'RESTRICT'];
}
return $fields;
}
示例6: generate
/**
* Create array of all the fields for a table
*
* @param string $table Table Name
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @param string $database
* @param bool $ignoreIndexNames
*
* @return array|bool
*/
public function generate($table, $schema, $database, $ignoreIndexNames)
{
$this->defaultConnection = DB::getDefaultConnection();
$this->database = $database;
$columns = $schema->listTableColumns($table);
if (empty($columns)) {
return false;
}
$indexGenerator = new IndexGenerator($table, $schema, $ignoreIndexNames);
$fields = $this->setEnum($this->getFields($columns, $indexGenerator), $table);
$fields = $this->getTableProperty($fields, $table);
$indexes = $this->getMultiFieldIndexes($indexGenerator);
return array_merge($fields, $indexes);
}
示例7: __construct
/**
* @param string $table Table Name
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @param bool $ignoreIndexNames
*/
public function __construct($table, $schema)
{
$this->indexes = array();
$this->multiFieldIndexes = array();
$indexes = $schema->listTableIndexes($table);
foreach ($indexes as $index) {
$indexArray = $this->indexToArray($table, $index);
if (count($indexArray['columns']) == 1) {
$columnName = $indexArray['columns'][0];
$this->indexes[$columnName] = (object) $indexArray;
} else {
$this->multiFieldIndexes[] = (object) $indexArray;
}
}
}
示例8: testCompositeForeignKeys
public function testCompositeForeignKeys()
{
$this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue($this->getFKDefinition()));
$fkeys = $this->manager->listTableForeignKeys('dummy');
$this->assertEquals(1, count($fkeys), "Table has to have one foreign key.");
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $fkeys[0]);
$this->assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
$this->assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
}
示例9: getForeignKeyConstraint
/**
* @param string $table
* @param string $column
* @return string
* @throws \Exception
*/
private function getForeignKeyConstraint($table, $column)
{
$keys = $this->schemaManager->listTableForeignKeys($table);
foreach ($keys as $key) {
if (in_array($column, $key->getLocalColumns(), false)) {
return $key->getName();
}
}
throw new \Exception('Foreign key constraint not found.');
}
示例10: onSuccess
public function onSuccess(Form $form)
{
if (!Callback::create($this->checkConnection)->invoke() || !$this->schemaManager->tablesExist('users')) {
return;
}
$presenter = $form->presenter;
$logEntity = new LogEntity($this->user instanceof UserEntity ? $this->user : NULL, 'Venne\\Forms\\Form', NULL, LogEntity::ACTION_OTHER);
$logEntity->setType($presenter->link('this'));
$logEntity->setMessage('Configuration has been updated');
$this->logRepository->save($logEntity);
}
示例11: __construct
public function __construct()
{
$this->schema = DB::getDoctrineSchemaManager();
$this->schema->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$this->tables = $this->schema->listTables();
$this->relationships = [];
//first create empty ruleset for each table
foreach ($this->tables as $table) {
$this->relationships[$table->getName()] = ['hasMany' => [], 'hasOne' => [], 'belongsTo' => [], 'belongsToMany' => []];
}
// get all relationships into $this->relationships variable
$this->getAllRelationships();
}
示例12: __construct
/**
* constructor
* @param string $table_name
* @param Connection $conn
*/
public function __construct($table_name, \Doctrine\DBAL\Connection $conn)
{
$this->conn = $conn;
$this->table_name = $table_name;
$this->quoted_table_name = $this->conn->quoteIdentifier($this->table_name);
$this->sm = $this->conn->getSchemaManager();
if (!$this->sm->tablesExist([$table_name])) {
throw Schema\SchemaException::tableDoesNotExist($table_name);
}
foreach ($this->sm->listTableColumns($this->table_name) as $colum) {
$this->columns[$colum->getName()] = $colum;
$this->column_types[$colum->getName()] = $colum->getType()->getName();
}
}
示例13: migrate
/**
* Migrates the database.
*
* @return Schema
*/
public function migrate()
{
$diff = Comparator::compareSchemas($this->manager->createSchema(), $this->schema);
foreach ($diff->toSaveSql($this->connection->getDatabasePlatform()) as $query) {
$this->connection->executeQuery($query);
}
}
示例14: executeChanges
/**
* Execute changes
*/
public function executeChanges()
{
$platform = $this->sm->getDatabasePlatform();
$sql = [];
if (count($this->changedIndexes)) {
foreach ($this->changedIndexes as $index) {
$sql[] = $platform->getDropIndexSQL($index);
$sql[] = $platform->getCreateIndexSQL($index, $this->table);
}
}
if (count($this->dropIndexes)) {
foreach ($this->dropIndexes as $index) {
$sql[] = $platform->getDropIndexSQL($index);
}
}
if (count($this->addedIndexes)) {
foreach ($this->addedIndexes as $index) {
$sql[] = $platform->getCreateIndexSQL($index, $this->table);
}
}
if (count($sql)) {
foreach ($sql as $query) {
$this->db->executeUpdate($query);
}
$this->changedIndexes = [];
$this->dropIndexes = [];
$this->addedIndexes = [];
}
}
示例15: get_views
/**
* Gets array \Doctrine\DBAL\Schema\View
*
* @return array
*/
public function get_views()
{
/**
* get views
*/
$views = $this->sm->listViews();
return $views;
}