Laravel中的mariaDB JSON支持 [英] mariaDB JSON support in Laravel

查看:354
本文介绍了Laravel中的mariaDB JSON支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在XAMP中创建一个json数据库,而使用phpmyAdmin时,它表明我正在使用mariaDB,但在我的xamp-control panel v3.2.2中,它表明正在运行mySQL on port 3306.我正在使用Laravel 5.4框架创建数据库,以下是我尝试执行的迁移:

I'm trying to create a json database in XAMP, while using the phpmyAdmin it showed me that I'm using mariaDB but in my xamp-control panel v3.2.2 it shows running mySQL on port 3306. I'm using Laravel 5.4 framework to create the database, following is my migration which I'm trying to execute:

Schema::connection('newPortal')->create('pages', function (Blueprint $table){
    $table->increments('id');
    $table->string('title');
    $table->string('slug')->unique()->index();
    $table->json('styles')->nullable();
    $table->json('content')->nullable();
    $table->json('scripts')->nullable();
    $table->softDeletes();
    $table->timestamps();
});

现在,执行此操作时出现以下错误:

Now while executing this I'm getting following error:

SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法有一个错误;请参阅第1914页的"SQLSTATE错误".检查与您的MariaDB服务器版本相对应的手册以获取正确的语法,以在第1行的'json null,content json null,scripts json null,deleted_at timestamp null'附近使用(SQL:create table pages (id int unsigned not null auto_increment主键,title varchar(191)不为空,slug varchar(191)不为空,styles json为空,content json为空,scripts json为空, deleted_at时间戳为null,created_at时间戳为null,updated_at时间戳为null)默认字符集utf8mb4整理utf8mb4_unicode_ci)

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json null, content json null, scripts json null, deleted_at timestamp null' at line 1 (SQL: create table pages (id int unsigned not null auto_increment primary key, title varchar(191) not null, slug varchar(191) not null, styles json null, content json null, scripts json null, deleted_at timestamp null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)

即使我保持不为null,它也会引发相同的错误.我想要json格式的数据,我检查了受支持的版本,并且根据文档json格式支持从版本MariaDB 10.0.16.开始,并且我正在使用10.1.21-MariaDB

Even if I keep not null it throws the same error. I want to have json formatted data, I checked the supported version and as per the documentation json format support started from the version MariaDB 10.0.16. and I'm using 10.1.21-MariaDB

在这方面帮助我.

推荐答案

从10.2.7版开始,MariaDB具有JSON数据类型的别名

MariaDB has alias for JSON datatype since version 10.2.7

使用此程序包将MariaDB JSON添加到Laravel

这篇关于Laravel中的mariaDB JSON支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆