如何使用查询的搜索结果来搜索另一个表

时间:2017-01-20 23:17:53

标签: yii yii2 yii2-advanced-app yii2-basic-app

我有以下代码搜索我有的表

$searchTax = new TaxonomySearch();
    $dataProviderTax = $searchTax->search(['TaxonomySearch'=>['tax_general'=>$spec]]);  

如何访问此搜索的结果,以便我可以使用结果搜索另一个表?

$searchModel = new NpiSearch();
        $dataProvider = $searchModel->search(['NpiSearch'=>['Provider_Business_Practice_Location_Address_Postal_Code'=>***results from dataProvidexTax***]]);            

并立即显示所有内容

1 个答案:

答案 0 :(得分:0)

阅读本文: findAll() in yii

您可能想要使用的其他方法:

$firstResults = results from findAll();
$fieldsToSearch = CHtml::listData($firstResults, 'fieldkeyselected', 'fieldvalueselected')
$additionalCondition = !empty($fieldsToSearch )?'field in ('.implode(',',$fieldsToSearch ).')':'';
... use findAll( $additionalCondition )