我对 FuelPHP 框架很陌生。现在我正在为位置列表实现“自动完成”。
我的代码如下所示:
public function action_search($term=null){
$clean_query = Security::clean($term);
$data["locations"] = array();
if ($clean_query != "") {
$data["locations"] = Model_Orm_Location::query()
->where("title", "like", $clean_query."%")
->get();
}
$response = Response::forge(View::forge("location/search", $data));
$response->set_header("Content-Type","application/json");
return $response;
}
正如你所看到的,我正在连接一个LIKE
语句,这让我感觉很糟糕。这段代码对 SQL 注入安全吗?如果是,那是因为:
Security::clean
将消除所有混乱;where()
在 ORM 查询中会做过滤吗?