how to retrieve values from two tables by a single criteria

how to retrieve values from two tables via a single criteria…i used like this

$vacation=new vacation;

$criteria=new CDbCriteria;

$criteria->select='approvalrequired,staffid';

$criteria->join='INNER JOIN vacationstaff ON vacation.vacationtype=vacationstaff.vacationtype';

$vaca=$vacation->findAll($criteria);

but it is used to check some condition in the second table.how do i get a value of particular field from the second table…

I think all you need to do is to modify your call to findAll:



<?php


$vacas=$vacation->with('vacationstaff')->findAll($criteria);


?>


This of course requires that you defined the relations of your tables within you vacation-AR.

I guess you can then access these objects like this:



<?php


foreach($vacas as $vaca)


{


  $staff=$vaca->vacationstaff;


  $value = $staff->someVacationstaffAttribute;


}


?>


k thanks…i used like this and it works…$vaca=vacationsta::model()->with(array('app'=>array('condition'=>'??.approvalrequired="'.$approvalrequired.'"','joinType'=>'INNER JOIN')))->findAll($criteria);

$pages=new CPagination($a);

if($p&gt;=0)


{


$pages-&gt;setCurrentPage($p);


}


if($pa&lt;=0)


{


$pages-&gt;pageSize=10;


}


else


{


$pages-&gt;pageSize=$pa;


}


$pages-&gt;applyLimit($criteria);


and this line $pages-&gt;applyLimit($criteria); cannot apply the offset and limit values to to the pagination .....if i give $vaca instead of $criteria i get error ..now the problem i have checked and got the answers which i need but i was unable to provide pagination all results are displayed ina single page..........and all pages displays all records