我正在尝试使用 PDO 在 mysql 中获取外部关联的表名。例如,我有:
用户表
+------------+----------+------+-----+-----+----------------+
| Field | Type | Null | Key | AI | Foreign Keys |
+------------+----------+------+-----+-----+----------------+
| id | int(255) | NO | PRI | yes | |
| username | char(16) | NO | | | |
| password | char(32) | NO | UNI | | |
| group | int(255) | NO | MUL | | mytable.group |
| created | datetime | NO | | | |
+------------+----------+------+-----+-----+----------------+
组表
+------------+----------+------+-----+-----+----------------+
| Field | Type | Null | Key | AI | Foreign Keys |
+------------+----------+------+-----+-----+----------------+
| id | int(255) | NO | PRI | YES | |
| name | char(16) | NO | UNI | | |
| description| TEXT | YES | | | |
+------------+----------+------+-----+-----+----------------+
我想动态地获取外部表 assoc(users.group => group) 的名称。SHOW COLUMNS 和 DESCRIBE 命令不显示关联。
如果有人知道该怎么做,我将不胜感激。谢谢!