问题描述
我是 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设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)