本文整理汇总了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;
}
}
}
示例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();
}
示例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());
}
示例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'));
}
}
}
示例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.");
}
示例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);
}
}
示例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;
}
示例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;
}