简体   繁体   中英

Why does Backpack demo crash on Article create or edit

When I run the backpack demo locally on my machine, and I want to edit or add an Article , the following error occurs:

SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error 
(SQL: SHOW COLUMNS FROM `articles` WHERE Field = "status")

This error does not happen on the online demo https://demo.backpackforlaravel.com/admin/article/create or https://demo.backpackforlaravel.com/admin/article/1/edit

As stated in the documentation: https://backpackforlaravel.com/docs/4.1/crud-fields#enum-1

PLEASE NOTE the enum field only works for MySQL databases.

When using SQLite, the solution is to change the enum type to a select_from_array type in the ArticleCrudController

 $this->crud->addField([
    'name' => 'status',
    'label' => 'Status',
    // 'type' => 'enum', // not supported by SQLite
    'type' => 'select_from_array',
    'options'  => [
        'PUBLISHED' => 'PUBLISHED', 
        'DRAFT' => 'DRAFT',
    ],
]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM