User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 423,608 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,277 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 802 | Replies: 0
Reply
Join Date: May 2007
Posts: 1
Reputation: gigtech is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gigtech gigtech is offline Offline
Newbie Poster

Question Discovering of Primary and Forign Keys using PHP?

  #1  
May 16th, 2007
Hi,
I have been trying to see how it is possible to get the name of the primary key column from the database by checking the constraint name. I have, up until now been unsuccessful. I have tried the below and I get nothing returned and no errors as well. Also, I am trying to find out how the code would differ for the foreign key.

By the way this is to be used in PHP so it should be able to return the results with no problem in PHP 4/5

Thanks

$query="SELECT COLUMN_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name='".$tablename."' AND CONSTRAINT_NAME='PRIMARY'";
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 8:38 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC