[quote name='seenivasan' timestamp='1358110273' post='188720']
Dear Friend
The method
queryRow brings the first row only.
The method
queryAll brings all the rows.
More over they are fetched as an array.
Kindly check whether the following is helpful in our case.
CONTROLLER
public function actionIndex()
{
$model=new Search;
if(isset($_POST['Search']))
{
$searchresult = Yii::app()->db->createCommand()
->select('p.product_id, p.product_name, r.price, p.master_key')
->from('tbl_product_index p')
->join('tbl_pricing r', 'p.product_id=r.product_id')
->where('master_key=:master_key', array(':master_key'=>$_POST['Search']['brand']['1']))
->queryAll();//fetching all rows...
$dataProvider=new CArrayDataProvider($searchresult);
$this->render('view',
array(
'dataProvider'=>$dataProvider,//pass $dataProvider not searchresult.
)
);
}
$this->render('index',array('model'=>$model,));
}
Thanks Seenivasan,this was helpful.
however now i am facing issue in creating command. the query provides an output if i remove the part which involves related tables (like r. price and Join sentence) but it gives empty result if using the below code.
if(isset($_POST['ProductIndex']))
{
$searchresult = Yii::app()->db->createCommand()
->select('p.product_id, p.product_name, r.price, p.master_key') //works fine without r.price
->from('tbl_product_index p')
->join('tbl_pricing r', 'r.product_id=p.product_id') //works fine without this sentence
->where('master_key=:master_key', array(':master_key'=>$_POST['ProductIndex']['brand']['1']))
->queryAll();
$dataProvider=new CArrayDataProvider($searchresult);
thanks for the help.