![]() |
User Type Query Problems - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: User Type Query Problems (/showthread.php?tid=56421) |
User Type Query Problems - El Forum - 12-18-2012 [eluser]Unknown[/eluser] The site I'm building needs to accommodate 3 different types of users. I'll be able to store some shared information about them in a general "users" table, but based on their type I'll need to store different data. So I've created separate tables for each user type so as to not end up with many empty fields in my user table. There is a "user_type" field in my users table but I'm just not sure how to perform the necessary join based on their type. Would it be best to retrieve basic user information and then perform a switch on the user's type to determine which table to join to and then run the proper query? Code: function userType($id) { Thanks in advance for your help! User Type Query Problems - El Forum - 12-25-2012 [eluser]vitoco[/eluser] [quote author="RedOak" date="1355846958"] Would it be best to retrieve basic user information and then perform a switch on the user's type to determine which table to join to and then run the proper query? [/quote] You're already retrieving all the user's information, because get_where returns "SELECT * ", so then you need only especific data of the user's user_type . User Type Query Problems - El Forum - 12-25-2012 [eluser]Aken[/eluser] You shouldn't try to combine one common table (users) with three tables that may or may not have data for each user. Because no matter what, each user will have two tables' worth of NULL columns, because none of that data exists. Perhaps you can explain your use case, because I don't see a real good efficient way of doing what you're asking. Maybe we can provide something better. |