在 Laravel returns 错误的时间戳中加入 where 查询
Join with where query in Laravel returns wrong timestamps
奇怪的事情发生了,我用下面的查询:
$bananafriends = IsFree::join('friendships', function($join)use($user) {
$join->on('arefree.user_id', '=', 'friendships.user_rec_id')
->where('friendships.user_send_id', '=', $user->id);
})
->get();
它 returns 友谊模型的时间戳和 ID 但不是 isFree 模型。
如果不起作用,我不明白为什么或如何从 isFree 模型中检索时间戳。
谢谢!
目前 select 正在相互覆盖。
您需要添加一个select:
$bananafriends = IsFree::join('friendships', function($join)use($user) {
$join->on('arefree.user_id', '=', 'friendships.user_rec_id')
->where('friendships.user_send_id', '=', $user->id);
})
->select('friendships.*', 'arefree.*', 'arefree.created_at as free_created')
->get();
请参阅 selects 上的文档:
http://laravel.com/docs/4.2/queries#selects
如果这不起作用,请告诉我,我会帮助您解决问题。
奇怪的事情发生了,我用下面的查询:
$bananafriends = IsFree::join('friendships', function($join)use($user) {
$join->on('arefree.user_id', '=', 'friendships.user_rec_id')
->where('friendships.user_send_id', '=', $user->id);
})
->get();
它 returns 友谊模型的时间戳和 ID 但不是 isFree 模型。 如果不起作用,我不明白为什么或如何从 isFree 模型中检索时间戳。
谢谢!
目前 select 正在相互覆盖。
您需要添加一个select:
$bananafriends = IsFree::join('friendships', function($join)use($user) {
$join->on('arefree.user_id', '=', 'friendships.user_rec_id')
->where('friendships.user_send_id', '=', $user->id);
})
->select('friendships.*', 'arefree.*', 'arefree.created_at as free_created')
->get();
请参阅 selects 上的文档:
http://laravel.com/docs/4.2/queries#selects
如果这不起作用,请告诉我,我会帮助您解决问题。