S
S
Senya2016-11-12 14:23:29
Yii
Senya, 2016-11-12 14:23:29

How to display contact information?

Good afternoon.
I have a messages table with messages:
id
message - message
from_whom - from whom to whom - to
whom
How to display those with whom the correspondence was conducted?
Tried to use

$this->hasOne(Users::className(), ['user_id' => 'from_whom']);

substituted for everyone and where, and orWhere and not user_id = my id, it doesn’t work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-11-12
@tyuty

Good afternoon.
As Maxim wrote, you need to link by user id (primary key) and if you don’t have a user_id field in the Users table, then how are you going to link by it? And in the from_whom field, I hope you have the user id and field type matches the field type in the users table?

M
Maxim Timofeev, 2016-11-12
@webinar

Based on standard practices, I think that you need not user_id, but just id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question