1. tbl_product_index(product_id,product_name,brand) product_id is primary key
and
2. tbl_pricing(product_id,price) product_id is primary key
here i use the relation:
in Pricing model:
public function relations() { return array( 'product' => array(self::BELONGS_TO, 'ProductIndex', 'product_id'), ); }
in ProductIndex model:
public function relations() { return array( 'pricing' => array(self::HAS_ONE, 'Pricing', 'product_id'), ); }
above code id genereted by the gii..
i want to show (product_id,product_name,brand,price) in CListView on index page of proxuctindex.
how to price data take from pricing table to productindex.
here i use
$productindex = ProductIndex::model()->findByPk(123); echo $productindex->pricing->price;
it gives the result of price value at primary key 123.
when i use in place of above code this
$productindex = ProductIndex::model()->findByPk($product_id); echo $productindex->pricing->price;
i found one error:
Undefined variable: product_id
how to solve this error?
i want to show all price value of product_id in CListView.
how to do this?
please help me..
thanks in advance