Welcome Guest, Not a member yet? Register   Sign In
get value from views and send it directly to model
#6

[eluser]rebornishard[/eluser]
[quote author="jprateragg" date="1353032383"]How did you do your join? Like this:

Code:
$this->db->join('user', 'post.user_id = user.id');

Can you post the query that didn't work?[/quote]

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

[quote author="rochellecanale" date="1353035756"]Try to execute traditional query.
Code:
$sql = "SELECT * FROM member
           RIGHT JOIN sales ON member.id = sales.id";
[/quote]
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

[quote author="Beginers" date="1353038429"]@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
Code:
print_r($data['postdata'])
if it really fetches the data you want.[/quote]

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

[quote author="Aken" date="1353053900"][quote author="Beginers" date="1353038429"]@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
Code:
print_r($data['postdata'])
if it really fetches the data you want.[/quote]
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.[/quote]

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


Messages In This Thread
get value from views and send it directly to model - by El Forum - 11-15-2012, 01:54 PM
get value from views and send it directly to model - by El Forum - 11-15-2012, 07:19 PM
get value from views and send it directly to model - by El Forum - 11-15-2012, 08:15 PM
get value from views and send it directly to model - by El Forum - 11-15-2012, 09:00 PM
get value from views and send it directly to model - by El Forum - 11-16-2012, 01:18 AM
get value from views and send it directly to model - by El Forum - 11-16-2012, 06:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB