- $table->timestamp('time')->default(\DB::raw('CURRENT_TIMESTAMP')); 数据库默认值为创建时间渐渐
-
$this->where('status',1)->groupBy('part_id')->select('part_id',DB::raw('group_concat(img) as sometitle'))->get()->toarray();
-
DB::connection()->enableQueryLog();#开启执行日志 // $result = $this->where('status',1)->groupBy('part_id')->select('part_id',DB::raw('group_concat(img) as sometitle'))->get()->toarray(); $result = $this->where('status',1)->select(['part_id'])->get()->toarray(); print_r(DB::getQueryLog());
- // 校验
$this->validate($request, [ 'Student.name' => 'required|min:2|max:20', 'Student.age' => 'required|integer', 'Student.sex' => 'required|integer', ],[ 'required' => ':attribute 为必填项', 'min' => ':attribute 长度不能小于2个字符', 'max' => ':attribute 长度不能大于20个字符', 'integer' => ':attribute 必须为数字', ],[ 'Student.name' => '用户名', 'Student.age' => '年龄', 'Student.sex' => '性别', ]);
$pic_id = array_pluck($pictureList,'pic_id');
新框架执行迁移时出错 :Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
解决:
- 升级MySql版本到5.7.7以上。
-
手动配置迁移命令
migrate
生成的默认字符串长度,把databales.php 里strict改为false ;在AppServiceProvider
中调用Schema::defaultStringLength
方法来实现配置:use Illuminate\Support\Facades\Schema; public function boot() { Schema::defaultStringLength(191); }