【问题标题】:How can I get company accounts in osclass如何在 osclass 中获取公司帐户
【发布时间】:2013-10-19 14:13:26
【问题描述】:

我的问题是如何在 osclass 中获得 公司帐户 https://osclass.org

【问题讨论】:

    标签: php mysql osclass


    【解决方案1】:
    //connect with database
    $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    if (!$link) 
    {
        // can't connect to database
        $counter_connected = false;
        die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
        exit;
    }
    
    //write sql query 
    $sql = "SELECT pk_i_id FROM oc_t_user WHERE b_company = 1";
    mysqli_query($link, "SET NAMES 'utf8'");
    $res = mysqli_query($link, $sql);
    
    if (mysqli_num_rows($res) > 0)
    {
        while($row = mysqli_fetch_assoc($res)){
            $users_id[] = 'fk_i_user_id = ' .$row['pk_i_id'];
        }
    
        $cond = implode($users_id, ' OR ');
    
        //if you have country session (optional)
        if(empty($_SESSION['_country'])){
            $_SESSION['_country'] = 'SY';
        }
    
        $sql = "SELECT u.pk_i_id AS id, r.pk_i_id AS img_id, u.i_price, d.s_title, u.fk_c_currency_code, l.fk_c_country_code
                FROM oc_t_item u, oc_t_item_description d, oc_t_item_resource r, oc_t_item_location l
                WHERE d.fk_c_locale_code = '".osc_current_user_locale()."'
                AND ( ".$cond." )
                AND l.fk_c_country_code = '".strtoupper($_SESSION['_country'])."'
                AND l.fk_i_item_id = u.pk_i_id
                AND r.fk_i_item_id = u.pk_i_id
                AND d.fk_i_item_id = u.pk_i_id
                GROUP BY u.pk_i_id
                ORDER BY u.pk_i_id DESC
                LIMIT 12 ";
        //get the final results of all conditions    
        $users = mysqli_query($link, $sql);    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多