The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#21
|
||||
|
||||
i honestly can't think of a way to do it all in one query.
|
#22
|
|||
|
|||
EDIT :
[SQL] COUNT(user.posts) AS totalteamposts, [/SQL] does the counting part - so no problems for me on counting problem is to set new value on teams.teamposts where teamid = teams.teamid Quote:
no-way there must be a way to figure it out.. |
#23
|
||||
|
||||
miz I'm finding it difficult to understand what you're trying to accomplish here. Can you just spend a couple of minutes thinking through about what you're asking and try and structure your request in a way we can understand it better. Thanks
|
#24
|
|||
|
|||
Quote:
i want my php page will show list of all teams on board then take all users on $teamid and count there posts then update teamposts in table teams this is the main idea now this query PHP Code:
now my qustion is : is there any way to combine the UPDATE of teams table with the query above now the easy way to do update is on the while loop but its mean the script will make 1 exstra query for each team so if i got 100 teams on board it will make 100 querys more then should be in other words, i want to update all teams info in 1 query how i can do that ? |
#25
|
||||
|
||||
You cannot do a select and update in one query. Drop the COUNT(user.posts) bit and then count the posts as you go along within the while loop. Before the while have $totalposts = 0; then in the while loop have $totalposts += $var['userposts'];
Then you do your update query outside the loop |
#26
|
|||
|
|||
Quote:
cuse every team got other count of posts and it got replaced in every time the while loop runs or i got you all worng can you show me exsample ? |
#27
|
||||
|
||||
Oh I see what you mean now, I thought you had a clause on the query to show that info for one team only. Um in that case a better idea would be to run a vB3 cron every 24hours to update the total posts for the team
|
#28
|
|||
|
|||
Quote:
this is what i made : PHP Code:
but im getting this error PHP Code:
[SQL] UPDATE teams SET posts=5 WHERE teamid=2;UPDATE teams SET posts=1 WHERE teamid=3;UPDATE teams SET posts=0 WHERE teamid=4;UPDATE teams SET posts=0 WHERE teamid=5;UPDATE teams SET posts=0 WHERE teamid=6;[/SQL] im getting this : [SQL] our SQL-query has been executed successfully SQL-query: UPDATE teams SET posts =5 WHERE teamid =2;# MySQL returned an empty result set (i.e. zero rows). UPDATE teams SET posts =1 WHERE teamid =3;# MySQL returned an empty result set (i.e. zero rows). UPDATE teams SET posts =0 WHERE teamid =4;# MySQL returned an empty result set (i.e. zero rows). UPDATE teams SET posts =0 WHERE teamid =5;# MySQL returned an empty result set (i.e. zero rows). UPDATE teams SET posts =0 WHERE teamid =6;# MySQL returned an empty result set (i.e. zero rows). [/SQL] so my qustion is what am i doing worng on php so its not working? i think we very close to get and answer. |
#29
|
||||
|
||||
You can only run one query at a time via mysql_query. Like I said above the most efficient way is via vBcron. I would strongly advise against running a query within a loop. And especially when it's being run everytime that page is loaded!
|
#30
|
|||
|
|||
i guss i dont have much options left
thanks for all of help to all of you guys |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|