Support

Home Forums Event Espresso Premium Event questions SQL question

Event questions SQL question

Posted: August 11, 2021 at 6:32 am

Viewing 2 reply threads


Embercombe

August 11, 2021 at 6:32 am

Hi we are trying to build a filterable table using the WP wp data plugin, that shows answers to Event questions (dietary requirements, emergency contact etc.) in columns with the questions as the headers. The table is not structured like this so we would need something like a pivot, but I noticed that there is a registration CSV report that can be downloaded that shows the answers next to the registrants details in comma seperated with the questions as the headers. Can you help me with how i could replicate the CSV output as a SQL query?


Tony

  • Support Staff

August 11, 2021 at 3:32 pm

Hi there,

The way the CSV generates this is to pull all of the question labels (be that all or for a specific event) and add them save those.

See here: https://github.com/eventespresso/event-espresso-core/blob/master/core/libraries/batch/JobHandlers/RegistrationsReport.php#L145

Then it pulls the registrations for the current report in batches of 50 and loops over each registration in the batch – HERE.

For each iteration of the loop it adds all of the question labels for the export into each individual row array (after adding all of the ‘default’ column for that row) – HERE.

Then pulls all of the answers related to that rows specific registration – HERE

Then finally, loops over each answer and uses the related question values return to then find the question_label for the specific answer and add the answer into the CSR array above based on that label – HERE.

I don’t think you’ll be able to do that within a single query using the registrations but does the above plugin allow you to run additional queries per row?


Embercombe

August 12, 2021 at 2:23 am

No I dont think so. We have built some views in mysql which we have then queried because using the plugin, in order to resolve some filtering issues across joins. Do you think this might work with a mysql view?

Viewing 2 reply threads

The support post ‘Event questions SQL question’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso