Support

Home Forums Custom Files Add-on (EE3) Adding a new database table

Adding a new database table

Posted: October 1, 2012 at 11:25 am

Viewing 8 reply threads


isavage

October 1, 2012 at 11:25 am

I need to create a new database table that has the wp_events_attendee info in it, but only for a specific event ID#, and only for folks that have a payment_status of “Completed.” Can you tell me how to do this?

My goal is to reference this table for a Moodle User Authentication & Class Enrollment purpose.

Or, is there a way to create an auto-updating table in phpmyadmin that mirrors the wp_events_attendee table, but with the filters as described above?


isavage

October 1, 2012 at 11:41 am

AFTER FURTHER CONSIDERATION, HERE’S WHAT WOULD BE IDEAL:


I need to program EE to export filtered attendee data (attendee info for a specific CATEGORY of class that have a payment_status of CONFIRMED) into a new table (I’d like to call it moodle_users).
This would be used for Moodle USER authentication, which is what allows the user to access the site.


Then, EE would create a different table for each of the “online” classes, that had ONLY the attendees that have a payment_status of CONFIRMED. These would need to be separated out by event_id, so that they could be independently linked to a specific class in Moodle.


I have no idea how to make this happen. But, if you can tell me what to do, I can implement it.


Josh

  • Support Staff

October 1, 2012 at 2:03 pm

Hi there,

If it’s something that can be accomplished by adding a few code snippets we can typically help, but this sort of request is well beyond the scope of support and into the realm of custom plugin development. I can recommend posting a job on our job board for this type of customization:
http://jobs.eventespresso.com/

or you could also contract with one of the Pros listed at WPCandy.com who have experience with custom plugin development and Event Espresso:
http://wpcandy.com/pros/experienced/with-event-espresso


isavage

October 1, 2012 at 2:59 pm

I see that you guys have “sponsored” jobs. Can you give me an idea of how many hours it would take for someone to do this?


Sidney Harrell

October 1, 2012 at 7:17 pm

It seems like you’d be better off just doing the query on the attendees table using a where (event_id = x or event_id = y) and (payment_status=”Completed”) whenever you need to check it for login. Otherwise, you’re going to have to do a lot to keep the new table in sync, and you’ll still need to query the new table.


Seth Shoultes

  • Support Staff

October 1, 2012 at 7:26 pm

We really don’t have enough information that tells us what format you need for the data or how exactly you see this working. But I can tell you that you don’t need to have additional tables for all of the different categories. You should just be able to write a function that queries the wp_events_attendee table for the event id and payment status.

Simple SQL statement (query) to retrieve the attendees that have paid: select * from wp_events_attendee where event_id = '1' and payment_status = 'Completed'

  • This reply was modified 12 years, 2 months ago by Seth Shoultes.
  • This reply was modified 12 years, 2 months ago by Seth Shoultes. Reason: fixing code


isavage

October 3, 2012 at 1:31 pm

Thanks Seth. That was very helpful. I was able to create a “view” in phpMyAdmin using this code, which allowed me to create another table.

Can you tell me how to add to this code so that I can also sort based on the category_id of the course? I know I need to reference the wp_events_category_rel table. But, that’s where my understanding ends.

Thanks!


isavage

October 7, 2012 at 10:25 am

So, I’ve figured out how to do this query, also referencing the other table. In case others may be interested, here’s the code:

SELECT [LIST COLUMN NAMES HERE THAT YOU WANT TO DISPLAY]
FROM
wp_events_attendee
JOIN wp_events_category_rel
WHERE cat_id = 'THE CATEGORY #' && payment_status = 'Completed' && wp_events_attendee.event_id = wp_events_category_rel.event_id
If you want to display columns that are shared between the two tables (like ‘id’ in this case) then you’d need to use the following format after the SELECT part: table_name.column_name
I’d really like to be able to only show attendee info that is less than 31 days after the payment_date. Does anyone know how to code those parameters into the above query?


isavage

October 7, 2012 at 4:15 pm

Solved by sticking this on the tail-end of the code above!
&& DATE_SUB( CURDATE( ) , INTERVAL 31
DAY ) <= DATE

Viewing 8 reply threads

The support post ‘Adding a new database table’ 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