Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我无法在 QueryBuilder 中重试此查询:
select id, lpad(number, 12, 0), lpad(int, 2, 0) from users;
我怎么能,在示例中不起作用...
DB::table('users') ->select('id', 'lpad(number, 12, 0)', 'lpad(int, 2, 0)' ->get();
你需要使用selectRaw.
selectRaw
DB::table('users') ->selectRaw('id, lpad(number, 12, 0), lpad(int, 2, 0)') ->get();
https://laravel.com/docs/8.x/queries#selectraw