even yii master and expert did nt solve this,even yii core developer did nt solve this.
i have table user_device
id-----user_id-------device_id
1 1 10
2 1 11
and table position
id-----time----------------------device_id----------data
1 2015-05-20 12:00:00 10 abc
2 2015-05-20 12:30:00 10 xdf
3 2015-05-20 12:30:00 10 xdf
4 2015-05-20 12:30:00 10 xdf
5 2015-05-20 12:30:00 11 xdf
6 2015-05-20 12:30:00 11 xdf
7 2015-05-20 12:30:00 11 xdf
now device is related to user and device is related to position table also
so i need data from position table but where it belongs to login user.
i have relation
public function getUserPosition()
{
return $this->hasMany(Positions::className(), ['device_id' => 'device_id']);
}
it should look like below
[0] => Array
(
[id] => 356114
[user_id] => 1
[device_id] => 10 //this is user_device data
[status] =>
[is_deleted] =>
[userPosition] => Array
(
[0] => Array
(
[id] => 356114
[device_id] => 10 //this is position data
[data] => abc
[time] => 2015-05-20 15:07:00
)
[1] => Array
(
[id] => 356114
[device_id] => 10
[data] => abc
[time] => 2015-05-20 15:07:34
)
[......
.....................
)
)
[1] => Array
(
[id] => 356114
[user_id] => 1
[device_id] => 11
[status] =>
[is_deleted] =>
[userPosition] => Array
(
[0] => Array
(
[id] => 356114
[device_id] => 11
[data] => abc
[time] => 2015-05-20 15:07:00
)
[1] => Array
(
[id] => 356114
[device_id] => 11
[data] => abc
[time] => 2015-05-20 15:07:34
)
[......
.....................
)
)
i need data from position table but where user_id is 1 and time between start_time and end_time and first need is device data from user_device and below subarray of realted data of device from position