問題描述
我是 Laravel 的新手 &今天我必須關閉嚴格的配置/數據庫文件,因為我需要在我的 SQL 查詢中使用 group by.在laravel 配置/數據庫中使用strict 有什么用,關閉它或strict = false 會影響網站嗎?它會使我們的網站安全性變弱嗎?在laravel 配置/數據庫中關閉嚴格的缺點是什么提前謝謝你?:)
I am new on laravel & today I have to turn off the strict in config/database file as I need to use group by in my SQL query. What is the use of strict in laravel config/database and by turning it off or strict = false will it affect the website? Will it make our website security weak? what is the disadvantage of turning strict off in laravel config/database Thank You in advance? :)
推薦答案
根據文檔:
嚴格模式控制 MySQL 如何處理 INSERT 或 UPDATE 等數據更改語句中的無效值或缺失值.由于多種原因,值可能無效.例如,它可能具有錯誤的列數據類型,或者可能超出范圍.當要插入的新行不包含在其定義中沒有顯式 DEFAULT 子句的非 NULL 列的值時,缺少值.(對于 NULL 列,如果缺少值,則插入 NULL.)嚴格模式也會影響 DDL 語句,例如 CREATE TABLE.
Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. (For a NULL column, NULL is inserted if the value is missing.) Strict mode also affects DDL statements such as CREATE TABLE.
在此處閱讀更多信息:https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
如果您在控制器中處理所有驗證并遵循 Laravel 開箱即用的最佳實踐,禁用它不會使您的網站不安全.
Disabling it wouldn't make your website unsecured if you handle all validations in your controllers and follow best practices like Laravel already does out of the box.
這篇關于Laravel 配置/數據庫中的 strict 有什么用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!