数据库中有表 database_product 和 database_orders,使用p.rid
和选择o.userid
。p
和如何o
定义为指向 database_product 和 database_orders?
$query = $wpdb->prepare("
SELECT p.rid, o.userid
FROM {$this->dbtable}_orders o
INNER JOIN {$this->dbtable}_product p ON p.productid = o.productid AND p.status = 'active'
WHERE o.oid = %d AND o.transaction_id = %s
LIMIT 1
",
$oid, $tid
);