我试图在外键更改中获取操作(在删除/更新时)。
我试图检查它查看 INFORMATION_SCHEMA.key_column_usage :
SELECT *
FROM `INFORMATION_SCHEMA`.`key_column_usage`
WHERE `referenced_table_schema` = '{$this->dbName}'
AND `referenced_table_name` IS NOT NULL
AND `table_name` = '{$this->tableName}'
它显示了这样的内容:
0 =>
array (size=12)
'CONSTRAINT_CATALOG' => string 'def' (length=3)
'CONSTRAINT_SCHEMA' => string 'test' (length=4)
'CONSTRAINT_NAME' => string 'profiles_ibfk_1' (length=15)
'TABLE_CATALOG' => string 'def' (length=3)
'TABLE_SCHEMA' => string 'test' (length=4)
'TABLE_NAME' => string 'profiles' (length=8)
'COLUMN_NAME' => string 'id' (length=2)
'ORDINAL_POSITION' => string '1' (length=1)
'POSITION_IN_UNIQUE_CONSTRAINT' => string '1' (length=1)
'REFERENCED_TABLE_SCHEMA' => string 'test' (length=4)
'REFERENCED_TABLE_NAME' => string 'users' (length=5)
'REFERENCED_COLUMN_NAME' => string 'id' (length=2)
....
我也尝试过 INFORMATION_SCHEMA.TABLE_CONSTRAITS ,我得到了:
0 =>
array (size=6)
'CONSTRAINT_CATALOG' => string 'def' (length=3)
'CONSTRAINT_SCHEMA' => string 'test' (length=4)
'CONSTRAINT_NAME' => string 'PRIMARY' (length=7)
'TABLE_SCHEMA' => string 'test' (length=4)
'TABLE_NAME' => string 'profiles' (length=8)
'CONSTRAINT_TYPE' => string 'PRIMARY KEY' (length=11)
....
在 2 种情况下,没有关于删除/更新操作的信息。
我能得到它?如何?如果我当然可以。