I'm trying to deal with wpdb but unfortunetelly things that I'm creating are not even close to reaching what I need. I have data:
seller ID (post_author = user_id) - $seller_id
and
(post_parent = transaction_id) - $ordernum
I have 3 tables:
wp_dopbsp_calendars
id
user_id
post_id name
max_year
hours_enabled
hours_interval_enabled
price_min
price_max
rating
address address_en
address_alt
address_alt_en
coordinates
wp_dopbsp_reservations
id
calendar_id
language
currency
currency_code
check_in
check_out
start_hour
end_hour
no_items
price
price_total
refund
extras
extras_price
discount
discount_price
coupon
coupon_price
fees
fees_price
deposit
deposit_price
days_hours_history
form
address_billing
address_shipping
email
status
payment_method
payment_status
transaction_id
token
date_created
and wp_posts
ID
post_author
post_date
post_date_gmt
post_content
post_title
post_excerpt
post_status
comment_status
ping_status
post_password
post_name
to_ping
pinged
post_modified
post_modified_gmt
post_content_filtered
post_parent
guid
menu_order
post_type
post_mime_type
comment_count
I need to create table and get its only record:
by seller ID (post_author = user_id) get calendar ID ("id" table wp_dopbsp_calendars) and post_parent ("post_parent" from wp_posts)
And with these two look for rows in table wp_dopbsp_reservations
, and get from there only the ones where transaction_id
is post_parent
(from wp_posts) and calendar_id
is id
(from wp_dopbsp_calendars
)
The columns that I need from this table are transaction_id
, calendar_id
, check_in
, check_out
, start_hour
, end_hour
and price_total
.
I couldn't go any further than this:
Select
$wpdb->posts.post_author,
$wpdb->dopbsp_calendars.user_id,
$wpdb->dopbsp_reservations.price_total,
$wpdb->dopbsp_reservations.check_in,
$wpdb->dopbsp_reservations.check_out,
$wpdb->dopbsp_reservations.start_hour,
$wpdb->dopbsp_reservations.end_hour,
$wpdb->dopbsp_calendars.id,
$wpdb->posts.post_title,
$wpdb->posts.ID As ID1,
$wpdb->posts.post_parent,
$wpdb->dopbsp_reservations.transaction_id
From
wp_posts
INNER JOIN $wpdb->posts.post_author ON $wpdb->dopbsp_calendars.user_id
$wpdb->dopbsp_calendars
On wp_posts.post_author = $wpdb->dopbsp_calendars.user_id,
$wpdb->dopbsp_reservations