Slagar Posted June 27, 2008 Share Posted June 27, 2008 I was just wondering if there is a simple way to find the Primary Key field(s) of a MySQL table. I've looked it up, and can only seem to find mysql_field_type, which doesn't seem to do what I want, so I thought someone here might know a way If not I'll likely just do a workaround -- have the last three characters of id fields consistently as "_id" in tables with composite keys or something. Cheers Link to comment https://forums.phpfreaks.com/topic/112148-solved-finding-pk-fields-from-a-mysql-table/ Share on other sites More sharing options...
hitman6003 Posted June 27, 2008 Share Posted June 27, 2008 use mysql_list_fields... http://www.php.net/mysql_list_fields Link to comment https://forums.phpfreaks.com/topic/112148-solved-finding-pk-fields-from-a-mysql-table/#findComment-575882 Share on other sites More sharing options...
Slagar Posted June 28, 2008 Author Share Posted June 28, 2008 Thanks for the tip Hitman. It turns out mysql_field_flags was what I was looking for (I must've missed it). www.php.net/mysql_field_flags Cheers Link to comment https://forums.phpfreaks.com/topic/112148-solved-finding-pk-fields-from-a-mysql-table/#findComment-576432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.