Skip to content

Commit

Permalink
fk support removed
Browse files Browse the repository at this point in the history
  • Loading branch information
krowinski committed Mar 9, 2017
1 parent 20620da commit fb2510a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
9 changes: 1 addition & 8 deletions src/MySQLReplication/Event/RowEvent/Columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@ public static function parse($columnType, array $columnSchema, BinaryDataReader
self::$field['unsigned'] = !(stripos($columnSchema['COLUMN_TYPE'], 'unsigned') === false);
self::$field['type_is_bool'] = false;
self::$field['is_primary'] = $columnSchema['COLUMN_KEY'] === 'PRI';
self::$field['is_foreign'] = null !== $columnSchema['REFERENCED_TABLE_NAME'] && null !== $columnSchema['REFERENCED_COLUMN_NAME'];

if (self::$field['is_foreign'])
{
self::$field['referenced_table_name'] = $columnSchema['REFERENCED_TABLE_NAME'];
self::$field['referenced_column_name'] = $columnSchema['REFERENCED_COLUMN_NAME'];
}


if (self::$field['type'] === ConstFieldType::VARCHAR)
{
self::$field['max_length'] = $binaryDataReader->readInt16();
Expand Down
4 changes: 1 addition & 3 deletions src/MySQLReplication/Event/RowEvent/RowEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ public function makeTableMapDTO()
'CHARACTER_SET_NAME' => null,
'COLUMN_COMMENT' => null,
'COLUMN_TYPE' => 'BLOB',
'COLUMN_KEY' => '',
'REFERENCED_TABLE_NAME' => '',
'REFERENCED_COLUMN_NAME' => '',
'COLUMN_KEY' => ''
];

$type = ConstFieldType::IGNORE;
Expand Down
28 changes: 9 additions & 19 deletions src/MySQLReplication/Repository/MySQLRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,18 @@ public function getFields($schema, $table)
{
$sql = '
SELECT
c.`COLUMN_NAME`,
c.`COLLATION_NAME`,
c.`CHARACTER_SET_NAME`,
c.`COLUMN_COMMENT`,
c.`COLUMN_TYPE`,
c.`COLUMN_KEY`,
`kcu`.`REFERENCED_TABLE_NAME`,
`kcu`.`REFERENCED_COLUMN_NAME`
`COLUMN_NAME`,
`COLLATION_NAME`,
`CHARACTER_SET_NAME`,
`COLUMN_COMMENT`,
`COLUMN_TYPE`,
`COLUMN_KEY`
FROM
`information_schema`.`COLUMNS` c
LEFT JOIN
`information_schema`.KEY_COLUMN_USAGE kcu
ON
c.`TABLE_SCHEMA` = kcu.`TABLE_SCHEMA`
AND
c.`TABLE_NAME` = kcu.`TABLE_NAME`
AND
c.`COLUMN_NAME` = kcu.`COLUMN_NAME`
`information_schema`.`COLUMNS`
WHERE
c.`TABLE_SCHEMA` = ?
`TABLE_SCHEMA` = ?
AND
c.`TABLE_NAME` = ?
`TABLE_NAME` = ?
';

return $this->getConnection()->fetchAll($sql, [$schema, $table]);
Expand Down

0 comments on commit fb2510a

Please sign in to comment.