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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.