我在使用 laravel migrate 命令时遇到问题。表明 :
SQLSTATE[42000]:语法错误或访问冲突:1071 指定的键太长;最大密钥长度为 1000 字节(SQL:alter table
usersadd uniqueusers_email_unique(
但是我的 mysql 版本是 5.7.14,我的字符集是:
mysql> show variables like "%char%";
+--------------------------+-------------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | D:\wamp64\bin\mysql\mysql5.7.14\share\charsets\ |
+--------------------------+-------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)
所以不应该像医生所说的那样有任何问题。有人可以帮助我吗?
我正在学习laravel 5.4。我知道有一个新的全局中间件将请求输入的空字符串转换为null。但是我有一个问题,网址是:http://localhost/choosePlan?type=1。我在控制器操作中得到类型字段值。如果请求输入中没有任何类型的文件,或者值是空的,那么我想将默认类型值设置为1。因此,在我的控制器操作中,我这样写:
$type = $request->input('type',1);
Run Code Online (Sandbox Code Playgroud)
只有我访问http://localhost/choosePlan才能获得类型默认值。如果我像访问,http://localhost/choosePlan?type还是http://localhost/choosePlan?type=仍然输入type为null。因此,我认为输入法的默认值只能在请求正文中没有文件名的情况下正常工作吗?以及如何解决以上问题?像确定类型为空,然后将其设置为默认值1?我不能禁用ConvertEmptyStringsToNull中间件,因为它在其他地方使用。谢谢。
更新:我只是测试禁用ConvertEmptyStringsToNull中间件,现在我得到的类型是空字符串。也许我误解了这种方法,我认为默认值只是针对请求中不存在的指定文件,而不是针对请求中存在的文件名,但值为空,是吗?哦,天哪,这意味着我也在Laravel 5.2中误解了。
我有一个关于 MySQL where 和子句的问题。下面两个说法是否相同:
1. select * from products where id <> 1 and num > 2
2. select * from products where (id <> 1 and num > 2)
Run Code Online (Sandbox Code Playgroud)