phpMyAdmin foreign key drop-down field values

爷,独闯天下 提交于 2019-12-21 07:55:23

问题


I'm using phpmyadmin (php & mysql) and I'm having a lot of trouble linking the tables using foreign keys.

I'm getting negative values for the field countyId (which is the foreign key). However it is linking to my other table fine and it's cascading fine.

When I go to add data there will be a drop box for the CountyId and the values look something like this,

-1

1-

Here is my alter statement:

ALTER TABLE Baronies
ADD FOREIGN KEY (CountyId)
REFERENCES Counties (CountyId)
ON DELETE CASCADE

回答1:


As i explained on ServerFault:

It is not negaitve number, the feature of phpMYAdmin is to show foreign key value and a custom description field next to it. In the referenced table (Counties) you can go to "Relation view" and under the table there is a select box "Choose field to display", in which you choose value that will be displayed next to CountyID value in the referencing table (Baronies). Also see: phpymadminWiki




回答2:


You can change the look of this dropdown using the ForeignKeyDropdownOrder option. (See the PMA documentation).

Example:

$cfg['ForeignKeyDropdownOrder'] = array( 'content-id');
/* 'content' is the referenced data, 'id' is the key value. */



回答3:


As Lex said, this is just the way phpMyAdmin displays the values. If you see "-1" or "1-" in that dropdown box, it's just 1.




回答4:


Check if your tables use MyIsam engine. In that case foreign keys are not supported. Use InnoDB instead.




回答5:


go to operation than change myiasm to innoDB than Go



来源:https://stackoverflow.com/questions/2476634/phpmyadmin-foreign-key-drop-down-field-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!