hola a18327 y para el resto del forum, se me hace presentado, una situacion curiosa, necesito en el grid mostrar un dato pero este es de una tercera tabla o sea seria algo asi, expresandolo en terminos como lo hacia en yii1
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('no_hc_a1',$this->no_hc_a1,true);
$criteria->with =array('entidadhcFk','fuenteDetFk','temahcFk','modoOperarFk','causasCondFk','cargoFk','[color="#FFFF00"]entidadhcFk.orgaFk[/color]','[color="#FFFF00"]entidadhcFk.provinciaFk[/color]','entidadhcFk.orgSubFk');
$criteria->addSearchCondition('entidadhcFk.enthc_nombre', $this->entidadhc_fk);
$criteria->addSearchCondition('[color="#FFFF00"]orgSubFk.org_sub_desc[/color]', $this->org_sub_desc);
$criteria->addSearchCondition('[color="#FFFF00"]provinciaFk.prov_desc[/color]', $this->prov_desc);
$criteria->addSearchCondition('[color="#FFFF00"]orgaFk.orga_hc_siglas[/color]', $this->orga_hc_siglas);
$criteria->addSearchCondition('fuenteDetFk.fuente_det_siglas',$this->fuente_det_fk)
el resultado de la parte marcada es lo que me interesa llevar a yii2 en el cual tengo esto
<?php
namespace app\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\Dictamen;
/**
* DictamenSearch represents the model behind the search form about `app\models\Dictamen`.
*/
class DictamenSearch extends Dictamen
{
public $entidad_nombre;
public $gepe_cod;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_dictamen', 'entidad_fk', 'consulta_fk'], 'integer'],
[['dict_fecha_sal_cecm','entidad_nombre','gepe_cod', 'dict_fecha_rec_mac', 'dict_no_dict', 'dict_fecha_resp', 'dict_rs', 'dict_no_acuerd_cecm'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Dictamen::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$dataProvider->sort->attributes['entidad_nombre'] = [
// The tables are the ones our relation are configured to
// in my case they are prefixed with "tbl_"
'asc' => ['dictamen.entidad_fk' => SORT_ASC],
'desc' => ['dictamen.entidad_fk' => SORT_DESC],
];
$dataProvider->sort->attributes['gepe_cod'] = [
// The tables are the ones our relation are configured to
// in my case they are prefixed with "tbl_"
'asc' => ['dictamen.consulta_fk' => SORT_ASC],
'desc' => ['dictamen.consulta_fk' => SORT_DESC],
];
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->joinWith(['entidadFk','consultaFk.gepeFk']);
$query->andFilterWhere([
'id_dictamen' => $this->id_dictamen,
'entidad.entidad_nombre' => $this->entidad_nombre,
'dict_fecha_sal_cecm' => $this->dict_fecha_sal_cecm,
'dict_fecha_rec_mac' => $this->dict_fecha_rec_mac,
'dict_fecha_resp' => $this->dict_fecha_resp,
'gepe.gepe_cod' => $this->gepe_cod,
]);
$query->andFilterWhere(['like', 'dict_no_dict', $this->dict_no_dict])
->andFilterWhere(['like', 'dict_rs', $this->dict_rs])
->andFilterWhere(['like', 'dict_no_acuerd_cecm', $this->dict_no_acuerd_cecm]);
return $dataProvider;
}
}
lo cual no me funciona , yo lo que necsito saber es como poner algo como esto
dictamen.consultaFk.gepeFk
para poder acceder a mi campo en la tabla gepe relacionado con el dictamen ya que necesito en el gridview filtrar por este criterio, alguna idea?? se los agradeceré