Laravel: Difference between revisions
Created page with " == SQL 查詢語法 Where 變數部分使用問號 == {{exclaim}} "Raw statements will be injected into the query as strings, so you should be extremely careful to not creat..." |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
[https://laravel.com/ Laravel - The PHP Framework For Web Artisans] (繁體中文文件: [https://laravel.tw/ Laravel - 為網頁藝術家創造的 PHP 框架]) | |||
== SQL 查詢語法 Where 變數部分使用問號 == | == SQL 查詢語法 Where 變數部分使用問號 == | ||
| Line 15: | Line 16: | ||
$query = DB::table("articles") | $query = DB::table("articles") | ||
->select("content") | ->select("content") | ||
->whereRaw("content LIKE ? ", [ | ->whereRaw("content LIKE ? ", ["%$search_keyword%"]) | ||
</pre> | </pre> | ||
| Line 22: | Line 23: | ||
$query = DB::table("articles") | $query = DB::table("articles") | ||
->select("content") | ->select("content") | ||
->where("content", "LIKE", | ->where("content", "LIKE", "%$search_keyword%") | ||
</pre> | </pre> | ||