SQL query on bookings database
-
Hey there,
I need to run a simple SQL query on the bookings database wp_em_bookings of the plugin Events Manager. I am using the newest version of both WordPress and the plugin.Say, I want to check the booking status of a specific user and echo it:
<?php global $wpdb; global $EM_Event; global $current_user; get_currentuserinfo(); $userid = $current_user->ID; $eventid = $EM_Event->id; $mybookings = $wpdb->get_results("SELECT * FROM $wpdb->em_bookings WHERE event_id = $eventid AND person_id = $userid"); foreach ($mybookings as $mybooking) { echo $mybooking->booking_status; } ?>
But whatever I’m using, either $wpdb->query or get_results, I can’t get my query to access the database tables. I tried to replace $wpdb->em_bookings with ‘$wpdb->prefix . EM_BOOKINGS_TABLE;” (found this in another forum post), but still no result. I tried adding the output_type for an array, nothing.
I even replaced all variables with actual numbers, id’s existing in the table. Nothing.
If I output only the variables $userid and $eventid from above, it’s giving me the right numbers. If I run a SELECT query on a normal wordpress database table, e.g. wp_links, it’s working as well.
Do I need to set a different global variable??
What am I doing wrong?
Help greatly appreciated!
Thanks, Christiane
- The topic ‘SQL query on bookings database’ is closed to new replies.