update `access_tokens` as at3 set at3.`expires` = 1393995576
where
`access_token_expires` > 1393995576
and at3.`id` in (select * from (
select `at2`.`id` from `refresh_tokens` as `rt`
left join `access_tokens` as `at` on `at`.`id` = `rt`.`access_token_id`
inner join `access_tokens` as `at2` on `at2`.`session_id` = `at`.`session_id`
where `rt`.`refresh_token` = 's2kF5Ev6NXncnTPwVz99ksgsCGXfwPIDzXJMZJqz') as t)
我正在尝试使用查询构建器在laravel 4中进行上述查询。但是无法找到如何写这个。我写到这个:
DB::table("access_tokens as at3")
->whereIn('id', function($query) use ($authParams)
{
$query->select('at2.id')
->from('refresh_tokens as rt')
->leftJoin("access_tokens as at", "at.id", "=", "rt.session_access_token_id")
->join("access_tokens as at2", "at2.session_id", "=", "at.session_id")
->where('rt.refresh_token', '=', $authParams['refresh_token']);
})
//->delete();
->where('at3.access_token_expires', '>', time())
->update(array('at3.access_token_expires' => time()));
答案 0 :(得分:0)
如果您只需要查询,则可以使用以下语法:
$affected_rows = DB::update( DB::raw("UPDATE users set username = 'wadus' WHERE username = :somevariable"), array('somevariable' => $someVariable));
它有效并且安全。