Join is not behaving as expected. - 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: Join is not behaving as expected. (/showthread.php?tid=57173) |
Join is not behaving as expected. - El Forum - 02-22-2013 [eluser]CloakandPigeon[/eluser] Hello, kind of new here and just wanted to post up an issue I am running into currently. I am attempting a join between an articles and users table so that I can pull the username column instead of printing out an ID number (it isn't very helpful to just have a number when trying to determine who the article belongs to). I have the following code in my model: Code: $this->db->select('articles.*', 'users.*'); All fields are available to me when I pass it to the view from the articles table, but none of them are available from the users table. I have attempted with the 'left' parameter added as well. Am I using the join command properly? I am wanting to get a table with columns for everything in articles and added to that I want to be able to pull the username info from the users table. Join is not behaving as expected. - El Forum - 02-22-2013 [eluser]Aken[/eluser] Your select() method is wrong. Items are not passed as parameters; they should either be a string or an array in the first parameter. Check the docs. Join is not behaving as expected. - El Forum - 02-22-2013 [eluser]CloakandPigeon[/eluser] [quote author="Aken" date="1361577294"]Your select() method is wrong. Items are not passed as parameters; they should either be a string or an array in the first parameter. Check the docs. [/quote] Yeh, I think I messed that up after attempting a few different solutions I found while researching (none of which worked). I originally had it set to select all (select(*)). From your experience does my join statement look like it would work for what I am wanting? Thanks again for your help. Join is not behaving as expected. - El Forum - 02-23-2013 [eluser]CloakandPigeon[/eluser] Nevermind, I am an idiot and Aken was correct, my select statement was messing up my query. Thanks Aken! |