I am using yii2 to make a query:
Usuarios
------------
juan
pedro
oscar
Tarjetas
------------
juan 123
pedro 987
oscar 657
oscar 987
I mean I have less users than cards , one has 2 cards. If I make this query:
select * from Usuarios leftJoin Tarjetas On idusuario = idUsuarioTarjeta
He returns everything to me; that is:
juan 123
pedro 987
oscar 657
oscar 987
But if I do that same in yii2
already with the relationships in the models and everything:
find()->joinwith('tarjetas');
The gridview
only returns this:
juan 123
pedro 987
oscar 657
If I make a find()->joinwith('tarjetas')->select('nombreUsuario, interbancariaCuenta');
I get what I want, but the gridview
no longer recognizes the card values, that is, the gridview no longer recognizes tarjetas.interbancariaCuenta
.
I have already changed the ratio of hasMany
to hasOne
, but still:
juan nodefinido
pedro nodefinido
oscar nodefinido
oscar nodefinido
I know I can do the search not inverted, cards- > joinleft to Users , and we would have what I want to do, but as I plan to join it with other tables, I'll use the inverted one so that I threw n
number of times the users and each of the accounts or cards.
It should be noted that if I do a select
direct in mysql it does it without any problem and gives me all the values I want, it's just the issue with the yii2
How can I resolve this situation?