0

テーブルに参加し、そのテーブルから位置と pricebycat1 を減算する必要がありますが、codeigniter の機能を理解できません。

これは、製品を取得するための私の機能です。

function get_product($id, $related=true)
{
    $result = $this->db->get_where('products',array('id'=>$id))->row();
    // get position, pricebycat1, join category_products 'category_products.product_id=products.id'
    if(!$result) {
        return false;
    }
    $related = json_decode($result->related_products);
    if(!empty($related)) {
        //build the where
        $where = false;
        foreach($related as $r) {
            if(!$where) {
                    $this->db->where('id', $r);
            } else {
                    $this->db->or_where('id', $r);
            }
            $where = true;
        }
        $result->related_products = $this->db->get('products')->result();
    } else {
        $result->related_products = array();
    }
    $result->categories = $this->get_product_categories($result->id);
    // group discount?
    if($this->group_discount_formula) {
        eval('$result->price=$result->price'.$this->group_discount_formula.';');
    }
    return $result;
}

どんな助けでも大歓迎です。

4

1 に答える 1