What is the use of strict in laravel config/database?

17,997

According to the doc:

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.

Read more here: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict

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.

Share:
17,997

Related videos on Youtube

iambegineer
Author by

iambegineer

Updated on September 16, 2022

Comments

  • iambegineer
    iambegineer over 1 year

    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? :)

  • iambegineer
    iambegineer about 7 years
    Hello, Eddy TheDove. Thank you so much. :)