2
我對FuelPHP框架頗爲陌生。現在我正在爲位置列表實現「自動完成」。在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查詢中會做過濾嗎?
一個很好的答案!感謝您深入挖掘框架! – naivists