source/Spiral/Database/Drivers/MySQL/Schemas/MySQLTable.php 1 location
|
@@ 127-138 (lines=12) @@
|
| 124 |
|
); |
| 125 |
|
|
| 126 |
|
$result = []; |
| 127 |
|
foreach ($references as $schema) { |
| 128 |
|
$column = $this->driver->query( |
| 129 |
|
'SELECT * FROM `information_schema`.`key_column_usage` WHERE `constraint_name` = ? AND `table_schema` = ? AND `table_name` = ?', |
| 130 |
|
[$schema['CONSTRAINT_NAME'], $this->driver->getSource(), $this->getName()] |
| 131 |
|
)->fetch(); |
| 132 |
|
|
| 133 |
|
$result[] = MySQLReference::createInstance( |
| 134 |
|
$this->getName(), |
| 135 |
|
$this->getPrefix(), |
| 136 |
|
$schema + $column |
| 137 |
|
); |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
return $result; |
| 141 |
|
} |
source/Spiral/Database/Drivers/Postgres/Schemas/PostgresTable.php 1 location
|
@@ 86-98 (lines=13) @@
|
| 83 |
|
$query = "SELECT * FROM pg_indexes WHERE schemaname = 'public' AND tablename = ?"; |
| 84 |
|
|
| 85 |
|
$result = []; |
| 86 |
|
foreach ($this->driver->query($query, [$this->getName()]) as $schema) { |
| 87 |
|
$conType = $this->driver->query( |
| 88 |
|
'SELECT contype FROM pg_constraint WHERE conname = ?', |
| 89 |
|
[$schema['indexname']] |
| 90 |
|
)->fetchColumn(); |
| 91 |
|
|
| 92 |
|
if ($conType == 'p') { |
| 93 |
|
//Skipping primary keys |
| 94 |
|
continue; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
$result[] = PostgresIndex::createInstance($this->getName(), $schema); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
return $result; |
| 101 |
|
} |