XF 2.2 Adding polls via the database. Your help needed confirming some stuff, please

Stuart Wright

Well-known member
I have 287 threads that I want to add a poll to. The poll responses are the same for all the polls, simplifying the process of adding them.
But adding them manually would take hours and hours and hours, so I want to do it with queries.
I think answering this might need input from one of the dev team.

Assuming nobody else creates a poll before or during this process...

First, for each thread I need to change the thread type from discussion to poll.
Then add each new xf_poll record for 287 polls (I've created 287 queries with the correct information. This is the first one:
INSERT INTO xf_poll (content_type,content_id,question,responses,voter_count,public_votes,max_votes,close_date,change_vote,view_results_unvoted) VALUES ('thread',821,'Please rate your experience at Chorley Motor Group Burnley (anonymous poll), '{"61:{response":"5 - Excellent","response_vote_count":0,"voters":[]},"62":{"response":"4 - Good","response_vote_count":0,"voters":[]},"63:{response":"3 - Average","response_vote_count":0,"voters":[]},"64:{response":"2 - Not good","response_vote_count":0,"voters":[]},"65:{response":"1 - Terrible","response_vote_count":0,"voters":[]}}',0,0,1,0,1,1);

the next poll ID being 15 provided nobody creates a poll between now and when I run it.
And then add the poll responses for the 287 new polls. The next poll_response record is number 61.
INSERT INTO xf_poll_response (poll_id,response,response_vote_count,voters) VALUES (15,'5 - Excellent',0,'[]'),(15,'4 - Good',0,'[]'),(15,'3 - Average',0,'[]'),(15,'2 - Not good',0,'[]'),(15,'1 - Terrible',0,'[]');

Is that correct and is that all I have to do?
Last edited:
Top Bottom