[question - solved] Join - active record |
[eluser]wemago[/eluser]
oks i couldnt find any awnser for this in the forum. Code: $this->db->select('username'); I'm trying to get a username and all i get is this -> Quote:Object id #19 any idea why?it should give me the name. thanx
[eluser]Michael Wales[/eluser]
It's doing what it should - it's returning the result object that you requested. Now you need to do something with that result object, like: Code: if ($query->num_rows() > 0) { User Guide: Generating Query Results
[eluser]wemago[/eluser]
...ok...to me -> "DUH!" lol stupid me xD thanx for the tip wales
[eluser]wemago[/eluser]
oks, i'm doing something really stupid. what I'm trying to get is the username, I've got a table for articles where we can find a author_id, i wanna list all articles showing title, author name and publish date. to get the article info is everything ok and shows it all. how should i get the username? my first idea was to do a 2nd function in articles model where i would get the username but i forgot that i do a foreach in the view, what happens is that it gives the same username for all of them. so probably i should merge the get articles function with the get author do a join and foreach one time right? any tip? p.s- I'm really slippy so sorry for the confusion
[eluser]wemago[/eluser]
ok...and again...DUH... lol i really need a sleep. for those who need an answer for this, this is what i did and works Code: $this->db->select('lab_users.username,lab_articles_categories.category_title, lab_articles.*');
[eluser]awpti[/eluser]
One thing I do in my models: $this->db->..... $data = $this->db->get('table'); return $data->result(); No sense in returning the result object when you can just return the data and start manipulating it right off the bat. Example: Code: function countup($link_id) { |
Welcome Guest, Not a member yet? Register Sign In |