gpt4 book ai didi

database - Laravel SelectRaw 与数据库 :Raw

转载 作者:搜寻专家 更新时间:2023-10-30 20:16:59 26 4
gpt4 key购买 nike

首先:

 DB::table('someTable')
->selectRaw('count(*), min(some_field) as someMin, max(another_field) as someMax')
->get();

第二:

DB::table('someTable')->select(
array(
DB::raw('min(some_field) as someMin'),
DB::raw('max(another_field) as someMax'),
DB::raw('COUNT(*) as `count`')
)
)->get()

The above two query result is same , but my question is there any possible security issues(SQL injections) with these two queries if i use user inputs directly in where conditions.

最佳答案

根据 Laravel 的 documentation :

Note: The Laravel query builder uses PDO parameter binding to protect your application against SQL injection attacks. There is no need to clean strings being passed as bindings.

关于database - Laravel SelectRaw 与数据库 :Raw,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34408900/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com