简体   繁体   中英

Query SQL Cannot work with Controller Laravel 5

Here is the SQL Query

SELECT sum(statement.amount)
FROM statement, lender
WHERE statement.type = 01
AND lender.id = statement.lender_id
AND statement.stat = 888
AND lender.user_id = users.id

And this is my code in controller

$count_totaldeposit = DB::table('statement')->join('lender','lender.id', '=', 'statement.lender_id')
                                            ->where('lender.user_id',$userId)
                                            ->where('type',01)
                                            ->where('statement.stat',888)->sum('statement.amount');  

I don't know where the issue is, can anybody help me with the code?

I Just need to add ("") inside 01.

like this :

->where('type',"01")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM