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


PHP AbstractSchemaManager::listTables方法代码示例

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


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

示例1: _loadTables

 private function _loadTables()
 {
     if ($this->_tables === null) {
         $tables = $this->_sm->listTables();
         $this->_tables = array();
         foreach ($tables as $table) {
             $this->_tables[strtolower($table->getName())] = $table;
         }
     }
 }
开发者ID:matiasraies,项目名称:Symfony2Inta,代码行数:10,代码来源:DoctrineMetadata.php

示例2: __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

示例3: get_tables

 /**
  * Gets array \Doctrine\DBAL\Schema\Table
  *
  * @return array
  */
 public function get_tables()
 {
     /**
      * get tables
      */
     $tables = $this->sm->listTables();
     /**
      * unset ignore tables
      */
     $ignore_table_names = \Config::get('dbdocs.ignore_table_names', array());
     foreach ($ignore_table_names as $ignore_table_name) {
         foreach ($tables as $index => $table) {
             /* @var $table \Doctrine\DBAL\Schema\Table */
             if ($table->getName() == $ignore_table_name) {
                 unset($tables[$index]);
             }
         }
     }
     $ignore_table_name_regex = \Config::get('dbdocs.ignore_table_name_regex');
     if (!empty($ignore_table_name_regex)) {
         foreach ($tables as $index => $table) {
             /* @var $table \Doctrine\DBAL\Schema\Table */
             if (0 < preg_match($ignore_table_name_regex, $table->getName())) {
                 unset($tables[$index]);
             }
         }
     }
     return array_merge($tables, array());
 }
开发者ID:mp-php,项目名称:fuel-packages-dbdocs,代码行数:34,代码来源:dbdocs.php

示例4: testListTables

 public function testListTables()
 {
     $this->createTestTable('list_tables_test');
     $tables = $this->_sm->listTables();
     $this->assertType('array', $tables);
     $this->assertTrue(count($tables) > 0);
     $foundTable = false;
     foreach ($tables as $table) {
         $this->assertType('Doctrine\\DBAL\\Schema\\Table', $table);
         if ($table->getName() == 'list_tables_test') {
             $foundTable = true;
             $this->assertTrue($table->hasColumn('id'));
             $this->assertTrue($table->hasColumn('test'));
             $this->assertTrue($table->hasColumn('foreign_key_test'));
         }
     }
 }
开发者ID:andreia,项目名称:doctrine,代码行数:17,代码来源:SchemaManagerFunctionalTestCase.php

示例5: testListTables

 public function testListTables()
 {
     $this->createTestTable('list_tables_test');
     $tables = $this->_sm->listTables();
     $this->assertInternalType('array', $tables);
     $this->assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'.");
     $foundTable = false;
     foreach ($tables as $table) {
         $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Table', $table);
         if (strtolower($table->getName()) == 'list_tables_test') {
             $foundTable = true;
             $this->assertTrue($table->hasColumn('id'));
             $this->assertTrue($table->hasColumn('test'));
             $this->assertTrue($table->hasColumn('foreign_key_test'));
         }
     }
     $this->assertTrue($foundTable, "The 'list_tables_test' table has to be found.");
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:18,代码来源:SchemaManagerFunctionalTestCase.php

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

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

示例8: setRelations

 /**
  * @param EloquentModel $model
  * @return $this
  */
 protected function setRelations(EloquentModel $model)
 {
     $foreignKeys = $this->manager->listTableForeignKeys($this->addPrefix($model->getTableName()));
     foreach ($foreignKeys as $tableForeignKey) {
         $tableForeignColumns = $tableForeignKey->getForeignColumns();
         if (count($tableForeignColumns) !== 1) {
             continue;
         }
         $relation = new BelongsTo($this->cropPrefix($tableForeignKey->getForeignTableName()), $tableForeignKey->getLocalColumns()[0], $tableForeignColumns[0]);
         $model->addRelation($relation);
     }
     $tables = $this->manager->listTables();
     foreach ($tables as $table) {
         if ($table->getName() === $this->addPrefix($model->getTableName())) {
             continue;
         }
         $foreignKeys = $table->getForeignKeys();
         foreach ($foreignKeys as $name => $foreignKey) {
             if ($foreignKey->getForeignTableName() === $this->addPrefix($model->getTableName())) {
                 $localColumns = $foreignKey->getLocalColumns();
                 if (count($localColumns) !== 1) {
                     continue;
                 }
                 if (count($foreignKeys) === 2 && count($table->getColumns()) >= 2) {
                     $keys = array_keys($foreignKeys);
                     $key = array_search($name, $keys) === 0 ? 1 : 0;
                     $secondForeignKey = $foreignKeys[$keys[$key]];
                     $secondForeignTable = $secondForeignKey->getForeignTableName();
                     $relation = new BelongsToMany($this->cropPrefix($secondForeignTable), $table->getName(), $localColumns[0], $secondForeignKey->getLocalColumns()[0]);
                     $model->addRelation($relation);
                     break;
                 } else {
                     $tableName = $this->cropPrefix($foreignKey->getLocalTableName());
                     $foreignColumn = $localColumns[0];
                     $localColumn = $foreignKey->getForeignColumns()[0];
                     if ($this->isColumnUnique($table, $foreignColumn)) {
                         $relation = new HasOne($tableName, $foreignColumn, $localColumn);
                     } else {
                         $relation = new HasMany($tableName, $foreignColumn, $localColumn);
                     }
                     $model->addRelation($relation);
                 }
             }
         }
     }
     return $this;
 }
开发者ID:xvlady,项目名称:eloquent-model-generator,代码行数:51,代码来源:EloquentModelBuilder.php


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