2017-02-23 90 views
3

我试图在XAMP中创建json数据库,同时使用phpmyAdmin它显示我使用mariaDB,但在我的xamp-control panel v3.2.2它显示正在运行mySQL on port 3306。我使用Laravel 5.4框架来创建数据库,下面是我的移民,我正在努力执行:Laravel的mariaDB JSON支持

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(); 
}); 

现在在执行这个我收到以下错误:

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)

即使如果我保持不为空它会抛出相同的错误。我想要json格式的数据,我检查了支持的版本,并根据文档json格式支持从版本MariaDB 10.0.16.开始,我正在使用10.1.21-MariaDB

帮我在这里。

+0

您是否尝试过运行在数据库GUI或REPL该查询,然后评论查询的每一部分进行逐行?它可能会说明确切的问题是什么 – Spholt

回答

3

请注意,1064抱怨数据类型为“json”。这在MariaDB中尚未实现。

您可以使用Dynamic Columns来关闭它,它至少可以将它们提取到JSON语法中。

另一件事(可能是你指的是)CONNECT能够有一个JSON 表类型。 (不是类型。)

MySQL 5.7有一个名为JSON的数据类型,外加一堆函数来操纵这些类型。

1

MariaDB的有别名JSON数据类型,因为版本10.2.7

添加MariaDB的JSON与Laravel this package