所以我有一個名為 $contest->id 的引數,我想在這個查詢中傳遞它,但是在控制器 laravel 8 中。但是,我收到一個錯誤,說 A non-numeric value encountered
$scoreboard = DB::select(DB::raw("
select t.id as id_tim,
t.nama as team_name,
(select nomor from prg_questions where prg_contest_id = " $contest->id " ),
(select count(*)
from prg_submissions
where team_id = t.id
and status='Accepted'
and prg_question_id in
(select id from prg_questions where prg_contest_id = = " $contest->id " ))
as 'solved',
ifnull((select sum(skor)
from prg_submissions
where team_id = t.id
and status='Accepted'
and prg_question_id in
(select id from prg_questions where prg_contest_id = " $contest->id " )),0) as 'time'
from teams t
left join team_join_prg_contest p on t.id=p.team_id
where p.prg_contest_id = " $contest->id " )
order by 'solved' desc, 'time' asc"));
有誰知道如何解決這個問題?或者也許有人知道這個雄辯的模型?因為我已經試過了,而且太復雜了。謝謝你的幫助??????????
uj5u.com熱心網友回復:
由于錯誤的連接而發生錯誤。用點替換所有加號。
錯誤的串聯:
(select nomor from prg_questions where prg_contest_id = " $contest->id " ),
正確串聯:
(select nomor from prg_questions where prg_contest_id = " . $contest->id . " ),
(在 JavaScript 或其他一些語言中,您 用于連接,但在 PHP 中您應該使用.;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/400006.html
上一篇:根據.csv檔案的條件選擇一行
