laravel 学习

  1. $table->timestamp('time')->default(\DB::raw('CURRENT_TIMESTAMP'));   数据库默认值为创建时间渐渐
  2. $this->where('status',1)->groupBy('part_id')->select('part_id',DB::raw('group_concat(img) as sometitle'))->get()->toarray();
  3.   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());
  4. // 校验
    $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 

解决:

  1. 升级MySql版本到5.7.7以上。
  2. 手动配置迁移命令migrate生成的默认字符串长度,把databales.php 里strict改为false ;在AppServiceProvider中调用Schema::defaultStringLength方法来实现配置:

        use Illuminate\Support\Facades\Schema;
    
        public function boot()
        {
           Schema::defaultStringLength(191);
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值