本文整理汇总了PHP中Doctrine\DBAL\Schema\AbstractSchemaManager类的典型用法代码示例。如果您正苦于以下问题:PHP AbstractSchemaManager类的具体用法?PHP AbstractSchemaManager怎么用?PHP AbstractSchemaManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractSchemaManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:alanedwardes,项目名称:carbo,代码行数:10,代码来源:SchemaInformation.php
示例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);
}
开发者ID:19peaches,项目名称:laravel-generator,代码行数:21,代码来源:FieldParser.php
示例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;
}
开发者ID:mayconbordin,项目名称:laragen,代码行数:22,代码来源:FieldGenerator.php
示例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;
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:18,代码来源:mdb2schemawriter.php
示例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;
}
开发者ID:Goopil,项目名称:laravel-generator,代码行数:21,代码来源:ForeignKeyParser.php
示例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);
}
开发者ID:JosefMor,项目名称:migrations-generator,代码行数:24,代码来源:FieldGenerator.php
示例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;
}
}
}
开发者ID:19peaches,项目名称:laravel-generator,代码行数:20,代码来源:IndexParser.php
示例8: createTable
/**
* @param AbstractSchemaManager $schemaM
* @param Schema $schema
*
* @since 1.1.0
*
* @author Eddilbert Macharia (http://eddmash.com) <[email protected]>
*/
public function createTable($schemaM, $schema)
{
if ($schemaM->tablesExist('artists')) {
$schemaM->dropTable('artists');
}
if ($schemaM->tablesExist('user')) {
$schemaM->dropTable('user');
}
echo 'Tables :: ';
$UTable = $schema->createTable('user');
$UTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
$UTable->addColumn('name', 'string', ['length' => 60]);
$UTable->setPrimaryKey(['id']);
$myTable = $schema->createTable('artists');
$myTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
$myTable->addColumn('user_id', 'integer', ['unsigned' => true]);
$myTable->addColumn('name', 'string', ['length' => 60]);
$myTable->setPrimaryKey(['id']);
$myTable->addForeignKeyConstraint($UTable, array('user_id'), array('id'), array('onUpdate' => 'CASCADE'));
$schemaM->createTable($UTable);
$schemaM->createTable($myTable);
}
开发者ID:eddmash,项目名称:powerorm,代码行数:30,代码来源:Testdb.php
示例9: 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()));
}
开发者ID:barbondev,项目名称:mysql4-doctrine-driver,代码行数:9,代码来源:MySQL4SchemaManagerTest.php
示例10: 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.');
}
开发者ID:shopwareLabs,项目名称:SwagImportExport,代码行数:16,代码来源:Update02RemoveForeignKeyConstraint.php
示例11: 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);
}
开发者ID:svobodni,项目名称:web,代码行数:11,代码来源:FormLogListener.php
示例12: __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();
}
开发者ID:Goopil,项目名称:laravel-generator,代码行数:13,代码来源:ModelRelationshipsGenerator.php
示例13: __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();
}
}
开发者ID:schwaen,项目名称:doctrine-dbal-extensions,代码行数:19,代码来源:Model.php
示例14: 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);
}
}
开发者ID:pagekit,项目名称:pagekit,代码行数:12,代码来源:Utility.php
示例15: 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 = [];
}
}
开发者ID:Yame-,项目名称:mautic,代码行数:32,代码来源:IndexSchemaHelper.php
示例16: get_views
/**
* Gets array \Doctrine\DBAL\Schema\View
*
* @return array
*/
public function get_views()
{
/**
* get views
*/
$views = $this->sm->listViews();
return $views;
}
开发者ID:mp-php,项目名称:fuel-packages-dbdocs,代码行数:13,代码来源:dbdocs.php
示例17: _getPortableTableIndexesList
/**
* {@inheritdoc}
*/
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
{
$indexes = array();
foreach ($tableIndexes as $k) {
$k['primary'] = (bool) $k['primary'];
$indexes[] = $k;
}
return parent::_getPortableTableIndexesList($indexes, $tableName);
}
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:12,代码来源:DrizzleSchemaManager.php
示例18: tableExist
private function tableExist()
{
try {
$name = $this->em->getClassMetadata('RenderBundle:Queue')->getTableName();
return $this->sm->tablesExist($name);
} catch (\Exception $e) {
return false;
}
}
开发者ID:carloboy7,项目名称:ownsongmovie,代码行数:9,代码来源:CheckCommand.php
示例19: testAlterTableThrowsExceptionForChangedSpatialType
public function testAlterTableThrowsExceptionForChangedSpatialType()
{
$this->setExpectedException('\\RuntimeException', 'The geometry_type of a spatial column cannot be changed (Requested changing type from "POINT" to "LINESTRING" for column "point_2d" in table "points")');
$table = $this->sm->listTableDetails('points');
$tableDiff = new \Doctrine\DBAL\Schema\TableDiff('points');
$tableDiff->fromTable = $table;
$tableDiff->changedColumns[] = new ColumnDiff('point_2d', new \Doctrine\DBAL\Schema\Column('point_2d', Type::getType('geometry'), array('customSchemaOptions' => array('geometry_type' => 'LINESTRING'))), array('geometry_type'), $table->getColumn('point_2d'));
$this->sm->alterTable($tableDiff);
}
开发者ID:novikovsergey,项目名称:doctrine-postgis,代码行数:9,代码来源:DBALSchemaEventSubscriberTest.php
示例20: 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;
}
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:10,代码来源:SchemaManagerFunctionalTestCase.php
注:本文中的Doctrine\DBAL\Schema\AbstractSchemaManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论