我有以下sql查询
SELECT * FROM exams WHERE exams.id NOT IN (SELECT examId FROM testresults)
Run Code Online (Sandbox Code Playgroud)
如何将其转换为Laravel查询构建器格式?
谢谢.
以下是使用Laravel查询构建器的查询:
$begin = new DateTime('2016-07-01');
$end = new DateTime('2016-07-31');
$startDate = $begin->format('Y-m-d 00:00:00');
$endDate = $end->format('Y-m-d 23:59:59');
$deposit = $depositModel->select(DB::raw('user_deposit.user_id as user_id, sum(user_deposit.amount) as total_deposit, null as total_withdraw'))
->whereBetween('date_time', [$startDate, $endDate])
->where('user_deposit.status', 1)
->groupBy('user_deposit.user_id');
$withdraw = $withdrawModel->select(DB::raw('user_withdraw.user_id as user_id, null as total_deposit, sum(user_withdraw.amount) as total_withdraw'))
->whereBetween('user_withdraw.created_at', [$startDate, $endDate])
->where('user_withdraw.status', 1)
->groupBy('user_withdraw.user_id');
$deposit = $deposit->unionAll($withdraw);
$transaction = DB::table(DB::raw("({$deposit->toSql()}) t"))
->select('user_id', DB::raw("sum(total_deposit) as total_deposit_amount, sum(total_withdraw) as total_withdraw_amount"))
->groupBy('user_id')
->get();
Run Code Online (Sandbox Code Playgroud)
我希望得到如下结果:
"transaction": [
{
"user_id": 2,
"total_deposit_amount": "101.00",
"total_withdraw_amount": "50.50"
},
{
"user_id": …Run Code Online (Sandbox Code Playgroud) for (var i = 0; i < rows.length; i++) {
$('#rows').after('<tr>
<td>'+ i + 1 + '</td>'
<td>'+rows[i][\'title\']+'</td>
<td>'+rows[i][\'startTime\']+'
</tr>');
}
Run Code Online (Sandbox Code Playgroud)
在上面的jquery代码中,我想在我的html中使用"rows"类在div之后插入表行.但是,我收到了错误
Uncaught SyntaxError: Unexpected token ILLEGAL
Run Code Online (Sandbox Code Playgroud)
我可以知道什么是错的,我该如何解决?谢谢
如何在 Laravel 中执行多个其中操作?
$devices = DB::table('foo')
->select('foo.*')
->whereIn('bar1', $request->bar1)
->whereIn('bar2', $request->bar2)
->get();
Run Code Online (Sandbox Code Playgroud)
上面是我的示例代码,但它返回一个空数组。
laravel ×3
laravel-5 ×2
mysql ×2
php ×2
eloquent ×1
html ×1
javascript ×1
jquery ×1
jquery-after ×1
queue ×1