在laravel config/database中,strict的用途是什么? [英] What is the use of strict in laravel config/database?
问题描述
我对laravel&今天,我必须关闭config/database文件中的strict,因为我需要在SQL查询中使用group by.在laravel config/database中,strict的用途是什么?通过将其关闭或strict = false会影响网站吗?这会使我们的网站安全性变弱吗?在laravel config/database中严格关闭的缺点是什么?预先谢谢您? :)
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
Read more here: 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 config/database中,strict的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!