i have 2 table
tbl_pricing (product_id, mobile_type, price)
and other table
tbl_product_index(product_id, product_name, index).
relation establish by the gii generated code…
in productindex.php
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'pricing' => array(self::HAS_ONE, 'Pricing', 'product_id'),
);
}
and in
pricing.php
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'product' => array(self::BELONGS_TO, 'ProductIndex', 'product_id'),
);
}
in ProductIndexController :
i want to select mobile_type column in addinCondition.how mobile_type column found in ProductIndexController .
here i use this code:
public function actionIndex()
{
$model = new ProductIndex();
$product_id = (isset($_GET['ProductIndex']['product_id'])) ? $_GET['ProductIndex']['product_id'] : array();
CVarDumper::dump($product_id);
$criteria = new CDbCriteria();
if( count( $product_id ) > 0 )
{
$criteria->addInCondition( '`pricing`.`mobile_type`', $product_id, true, 'OR' );//how to select mobile_type column from tbl_pricing
}
$dataProvider = new CActiveDataProvider('ProductIndex',
array('criteria'=>$criteria));
$this->render('index',array(
'dataProvider'=>$dataProvider,
'model'=>$model,
));
}
here i found an error:
Error 500: <h1>CDbException</h1>
<p>CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘pricing.mobile_type’ in ‘where clause’. The SQL statement executed was: SELECT COUNT(*) FROM tbl_product_index
t
WHERE pricing
.mobile_type
=:ycp0.
how to solve this error.
pls help me.
Any help is appreciated to me …
thanks in advance…