Support

Home Forums Event Espresso Premium wp_events_detail – Some events category_id is NULL when it shouldn't be

wp_events_detail – Some events category_id is NULL when it shouldn't be

Posted: November 18, 2014 at 2:56 pm


sheathe

November 18, 2014 at 2:56 pm

While using the custom templates add-on, I noticed that the category filter was not behaving correctly.

Looking at the source code, I discovered that many events contained markup like the following:

<tr class="espresso-table-row cat-">

However, many of the events correctly displayed the category ids:

<tr class="espresso-table-row cat-4 cat-7 cat-12">

I checked inside the admin interface and confirmed that multiple categories were indeed set (checked off) for both of the above example events.

By using the following query in phpMyAdmin, however, I noticed that category_id is NULL for many events, but not for others:

SELECT e.*, ese.start_time, ese.end_time, p.event_cost , v.name venue_name, v.address venue_address, v.city venue_city, v.state venue_state, v.zip venue_zip, v.country venue_country, v.meta venue_meta, v.id venue_id FROM wp_events_detail e LEFT JOIN wp_events_start_end ese ON ese.event_id = e.id LEFT JOIN wp_events_prices p ON p.event_id=e.id LEFT JOIN wp_events_venue_rel vr ON vr.event_id = e.id LEFT JOIN wp_events_venue v ON v.id = vr.venue_id WHERE e.is_active = 'Y' AND (e.start_date >= '2014-11-18' OR e.event_status = 'O' OR e.registration_end >= '2014-11-18') AND e.event_status != 'D' AND e.event_status != 'S' GROUP BY e.id ORDER BY date(e.start_date), ese.start_time ASC

*** Is it possible that category_id is a new(er) field, which is why existing/old events do not have the categories listed in that field? I recently upgraded from 3.1.24.1.P all the way to 3.1.36.6.P.

Is there a query I can run to populate that field with the correct category ids?

Thank you,
Scott


Sidney Harrell

November 19, 2014 at 1:22 pm

Take a look at the wp_events_category_rel table and see if there are entries there which correspond to the categories assigned to one of the bad events. If the data is there, then you should be able to get it into the field in wp_events_details.
I apologize, I know it’s a violation of DB normalization, but it was probably done to maintain backwards compatibility in EE3’s long life.


sheathe

November 20, 2014 at 10:29 am

Thank you Sidney. FYI, after quite a bit of digging, I found the following post with a function that allowed me to avoid using category_id field:


sheathe

November 20, 2014 at 10:29 am

For some reason the link was stripped off:

https://eventespresso.com/topic/category_identifier-returns-null/


Dean

November 21, 2014 at 1:39 am

Thanks for posting your solution!

The support post ‘wp_events_detail – Some events category_id is NULL when it shouldn't be’ 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