Hi again im still learning, i want to show in a GridView a relation with hasMany, in my cuentas model i have
public function getContactos()
{
return $this->hasMany(Contactos::className(), ['cuenta_id' => 'idcuenta']);
}
Now, if i use this function on CuentasSearch only show on the View as many rows as Cuentas i have
public function search($params)
{
$dataProvider = new ActiveDataProvider([
'query' =>Cuentas::find()->joinWith('contactos')
]);
return $dataProvider;
}
But if i use pure SQL on CuentasSearch, it show as many rows as Contactos i have
public function search($params)
{
$dp = new SqlDataProvider([
'sql' => 'SELECT idcuenta, nombrecuenta from cuentas left join contactos
on cuentas.idcuenta = contactos.cuenta_id ',
]);
return $dp;
}
What happend if it is the same query and i want to show on the GridView all rows as Contactos i have, what is wrong, i can’t use last one because i want use filters.
Best Regards