it's a foreign key? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: it's a foreign key? (/showthread.php?tid=7674) |
it's a foreign key? - El Forum - 04-18-2008 [eluser]zizzo[/eluser] hi everyonee, i've a new question for youu, i've a method for knowing if a key it's a foreign key, but it's so looong...i would want know if there is a faster method to know if a key in a database's table it's a foreign key...and maybe also know which table refer.. perhaps my request it's not so clear.. it's a foreign key? - El Forum - 04-18-2008 [eluser]xwero[/eluser] if you name your fieldnames well it's easy to know if a field is foreign key or not. Code: is_foreign_key($fieldname) it's a foreign key? - El Forum - 04-18-2008 [eluser]gtech[/eluser] if you are using mysql you can do something like Code: select column_key from information_schema.columns where it's a foreign key? - El Forum - 04-20-2008 [eluser]zizzo[/eluser] if i try your query with myphpadmin i obtain a correct result (MUL or PRI), but when i use, in my controller, this: Code: $query="SELECT column_key FROM information_schema.columns in $foreign i have "Object id #15" mmm why? thanks it's a foreign key? - El Forum - 04-20-2008 [eluser]zizzo[/eluser] no idea? it's a foreign key? - El Forum - 04-20-2008 [eluser]gtech[/eluser] try Code: $query="SELECT column_key FROM information_schema.columns I get Code: Array ( [0] => Array ( [column_key] => MUL ) ) or Code: ... it's a foreign key? - El Forum - 04-21-2008 [eluser]zizzo[/eluser] Perfect solution!! With your hints i've solved! Thank youuu :coolsmile: |