jprateragg - 15 November 2012 10:19 PM
How did you do your join? Like this:
$this->db->join('user', 'post.user_id = user.id');
Can you post the query that didn’t work?
that one worked if i view all post list
post 1 made by user A
post 2 made by user B
post 3 made by user A
but if i view in user side
user A made post 1
user A made post 3
user B made post 2
the result i wanted
user A made post 1, post 3
user B made post 2
and
user A total post 2
user B total post 1
thank you jprateragg
rochellecanale - 15 November 2012 11:15 PM
Try to execute traditional query.
$sql = "SELECT * FROM member
RIGHT JOIN sales ON member.id = sales.id";
i already try that sir and then put that query in array but it still give me
user A made post 1
user A made post 3
user B made post 2
thank you rochellecanale
Beginers - 16 November 2012 12:00 AM
@rochellecanale -> Traditional query is not a good practice on doing the query. Active record was created so that it will become easier for us to do the query and more on that to have a lesser code.
@rebornishard -> I think your database has no data. Try to use
print_r($data['postdata'])
if it really fetches the data you want.
i always print_r or var_dump to test it before
this is not about data but about result i wanted to get
thank you Beginers
Aken - 16 November 2012 04:18 AM
Beginers - 16 November 2012 12:00 AM
@rochellecanale -> Traditional query is not a good practice on doing the query. Active record was created so that it will become easier for us to do the query and more on that to have a lesser code.
@rebornishard -> I think your database has no data. Try to use
print_r($data['postdata'])
if it really fetches the data you want.
Traditional query is perfectly fine. It’s up to the developer. Active record is there simply for convenience; it isn’t an expressed “best practice”.
You shouldn’t be calling models in your views. Fetch all the data you need in your controller, put it together in a way that your view expects, and then pass it to your view.
yes sir, i’m not using that, i just wanted to get this worked :
user A made post 1, post 3
user B made post 2
and
user A total post 2
user B total post 1
thank you Aken