mysql - join 2 table orders wordpress plugin

i have two table wp_wcfm_marketplace_orderswp_wcfm_affiliate_ordersi need call data where wp_wcfm_affiliate_orders.orde

i have two table wp_wcfm_marketplace_orders wp_wcfm_affiliate_orders

i need call data where wp_wcfm_affiliate_orders.orderid wp_wcfm_marketplace_orders.order_id

it code call data table wp_wcfm_affiliate_orders

    public function processing() {
        global $WCFM, $wpdb, $_POST, $WCFMu, $WCFMaf;

        $length = $_POST['length'];
        $offset = $_POST['start'];

        $affiliate_id = $_POST['wcfm_affiliate']; 
        $status          = $_POST['status_type'];

        $sql  = "SELECT COUNT(ID) FROM `{$wpdb->prefix}wcfm_affiliate_orders`";
        $sql .= " WHERE 1=1";
        $sql .= " AND {$wpdb->prefix}wcfm_affiliate_orders.affiliate_id = {$affiliate_id}";
        if( $status ) $sql .= " AND {$wpdb->prefix}wcfm_affiliate_ordersmission_status = '{$status}'";
        $sql .= ' AND `is_trashed` = 0';
        $affiliate_count = $wpdb->get_var( $sql );

        // Get Product Count
        $sql  = "SELECT  * FROM  {$wpdb->prefix}wcfm_affiliate_orders  ";
        $sql .= " WHERE 1=1";
        $sql .= " AND {$wpdb->prefix}wcfm_affiliate_orders.affiliate_id = {$affiliate_id} 

        ";
        if( $status ) $sql .= " AND {$wpdb->prefix}wcfm_affiliate_ordersmission_status = '{$status}'";
        $sql .= ' AND `is_trashed` = 0';
        $sql .= " ORDER BY `ID` DESC";
        $sql .= " LIMIT {$length}";
        $sql .= " OFFSET {$offset}";


        $wcfm_affiliate_orders_array = $wpdb->get_results( $sql );
        $wcfm_affiliate_order_count  = count( $wcfm_affiliate_orders_array );

i have two table wp_wcfm_marketplace_orders wp_wcfm_affiliate_orders

i need call data where wp_wcfm_affiliate_orders.orderid wp_wcfm_marketplace_orders.order_id

it code call data table wp_wcfm_affiliate_orders

    public function processing() {
        global $WCFM, $wpdb, $_POST, $WCFMu, $WCFMaf;

        $length = $_POST['length'];
        $offset = $_POST['start'];

        $affiliate_id = $_POST['wcfm_affiliate']; 
        $status          = $_POST['status_type'];

        $sql  = "SELECT COUNT(ID) FROM `{$wpdb->prefix}wcfm_affiliate_orders`";
        $sql .= " WHERE 1=1";
        $sql .= " AND {$wpdb->prefix}wcfm_affiliate_orders.affiliate_id = {$affiliate_id}";
        if( $status ) $sql .= " AND {$wpdb->prefix}wcfm_affiliate_ordersmission_status = '{$status}'";
        $sql .= ' AND `is_trashed` = 0';
        $affiliate_count = $wpdb->get_var( $sql );

        // Get Product Count
        $sql  = "SELECT  * FROM  {$wpdb->prefix}wcfm_affiliate_orders  ";
        $sql .= " WHERE 1=1";
        $sql .= " AND {$wpdb->prefix}wcfm_affiliate_orders.affiliate_id = {$affiliate_id} 

        ";
        if( $status ) $sql .= " AND {$wpdb->prefix}wcfm_affiliate_ordersmission_status = '{$status}'";
        $sql .= ' AND `is_trashed` = 0';
        $sql .= " ORDER BY `ID` DESC";
        $sql .= " LIMIT {$length}";
        $sql .= " OFFSET {$offset}";


        $wcfm_affiliate_orders_array = $wpdb->get_results( $sql );
        $wcfm_affiliate_order_count  = count( $wcfm_affiliate_orders_array );
Share Improve this question edited Dec 7, 2019 at 19:14 l3lmk asked Dec 7, 2019 at 18:40 l3lmkl3lmk 214 bronze badges 1
  • Welcome to WordPress Development. I hope you find the answer(s) you are looking for. Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. – Matthew Brown aka Lord Matt Commented Dec 8, 2019 at 12:12
Add a comment  | 

1 Answer 1

Reset to default 0

// Get Product Count $sql = "SELECT wcfm_affiliate_orders.*, ya.order_id,ya.order_status FROM {$wpdb->prefix}wcfm_affiliate_orders AS wcfm_affiliate_orders LEFT JOIN {$wpdb->prefix}wcfm_marketplace_orders AS ya ON ya.order_id = wcfm_affiliate_orders.order_id "; $sql .= " WHERE 1=1"; $sql .= " AND wcfm_affiliate_orders.affiliate_id = {$affiliate_id}

    ";
    if( $status ) $sql .= " AND  wcfm_affiliate_ordersmission_status = '{$status}'";

    $sql .= " ORDER BY  wcfm_affiliate_orders.ID  DESC";
    $sql .= " LIMIT {$length}";
    $sql .= " OFFSET {$offset}";


    $wcfm_affiliate_orders_array = $wpdb->get_results( $sql );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744925757a4601425.html

相关推荐

  • mysql - join 2 table orders wordpress plugin

    i have two table wp_wcfm_marketplace_orderswp_wcfm_affiliate_ordersi need call data where wp_wcfm_affiliate_orders.orde

    1天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信