Laravel-Wampserver64-SQLSTATE [01000]:警告:1265行1的列“ District”的数据被截断

时间:2019-07-08 02:45:40

标签: sql laravel wamp64

我正在修改在Wampserver上创建的WebApp。我想在 CustomerData / Create 页面上添加名为'District'的下拉列表。

在fields.yaml上添加代码后:

    district:
        label: 'District'
        options:
            Ab: Aberdeen
            Ad: Admiralty
            Ap: Ap Lei Chau
            Ca: Causeway Bay
            Ce: Central
            H: Happy Valley
            K: Kowloon
            M: Mid Levels
            N: North Point
            Pe: Peak
            Po: Pok Fu Lam
            Q: Quarry Bay
            Sa: Sai Ying Pun
            Sh: Sheung Wan
            Ta: Taikoo Shing
            Ti: Tin Hau
            Wa: Wan Chai
            Wo: Wong Chuk Hang
            NT: NT
        span: left
        required: 1
        type: dropdown
        tab: 'Contact Information'

在MySQL Workbench上,我添加了'District'as ENUM('Kowloon','Central','North Point','Quarry Bay','Taikoo Shing','Tin Hau','Wan Chai','Happy谷”,“西营盘”,“半山”,“上环”,“薄扶林”,“金钟”,“坚尼地城”,“鸭梨洲”,“山顶”,“黄竹坑”, “ NT”,“铜锣湾”。

尽管如此,我仍然遇到以下错误:

  

SQLSTATE [010000]:警告:125列“ District”的数据已截断   第1行(SQL:在第664行的.....中插入   C:\ wamp64 ... \ Database \ Connection.php)

这是第664行的Connection.php代码:

protected function runQueryCallback($query, $bindings, Closure $callback)
{
    // To execute the statement, we'll simply call the callback, which will actually
    // run the SQL against the PDO connection. Then we can calculate the time it
    // took to execute and log the query SQL, bindings and time in our memory.
    try {
        $result = $callback($query, $bindings);
    }

    // If an exception occurs when attempting to run a query, we'll format the error
    // message to include the bindings with SQL, which will make this exception a
    // lot more helpful to the developer instead of just the database's errors.
    catch (Exception $e) {
        throw new QueryException(
            $query, $this->prepareBindings($bindings), $e
        );
    }

    return $result;
}

如何解决此错误?

2 个答案:

答案 0 :(得分:0)

在插入未专门枚举的ENUM值时(例如,它不是在创建列时插入的特定ENUM选项之一),会出现Data truncated for column...错误。

您的options:文件中的fields.yaml遵循键=>标签格式;这意味着冒号前面的值应该是实际的枚举值(例如,九龙或中央),然后是下拉菜单中使用的实际标签。

答案 1 :(得分:0)

非常感谢您的帮助,现在它可以工作了,我可以轻松地在数据库中创建新客户。 但是,我有一个新问题。网页http://localhost/backend/lss/eatology/customerdata/create有效(我可以创建新客户),但是http://localhost/backend/lss/eatology/customerdata不起作用。

这是错误的堆栈跟踪

“#Number-调用的代码文档-行”

65  Backend\Widgets\Lists->evalCustomListType(…)    ~/modules/backend/widgets/Lists.php 1016
64  Backend\Widgets\Lists->getColumnValue(…)    ~/modules/backend/widgets/lists/partials/_list_body_row.htm 27
63  include(…)  ~/modules/system/traits/ViewMaker.php   247
62  Backend\Classes\WidgetBase->makeFileContents(…) ~/modules/system/traits/ViewMaker.php   97
61  Backend\Classes\WidgetBase->makePartial(…)  ~/modules/backend/widgets/lists/partials/_list_body_rows.htm    2
60  include(…)  ~/modules/system/traits/ViewMaker.php   247
59  Backend\Classes\WidgetBase->makeFileContents(…) ~/modules/system/traits/ViewMaker.php   97
58  Backend\Classes\WidgetBase->makePartial(…)  ~/modules/backend/widgets/lists/partials/_list.htm  8
57  include(…)  ~/modules/system/traits/ViewMaker.php   247
56  Backend\Classes\WidgetBase->makeFileContents(…) ~/modules/system/traits/ViewMaker.php   97
55  Backend\Classes\WidgetBase->makePartial(…)  ~/modules/backend/widgets/lists/partials/_list-container.htm    2
54  include(…)  ~/modules/system/traits/ViewMaker.php   247
53  Backend\Classes\WidgetBase->makeFileContents(…) ~/modules/system/traits/ViewMaker.php   97
52  Backend\Classes\WidgetBase->makePartial(…)  ~/modules/backend/widgets/Lists.php 238
51  Backend\Widgets\Lists->render() ~/modules/backend/behaviors/listcontroller/partials/_container.htm  9
50  include(…)  ~/modules/system/traits/ViewMaker.php   247
49  Backend\Classes\Controller->makeFileContents(…) ~/modules/backend/classes/ControllerBehavior.php    143
48  Backend\Classes\ControllerBehavior->makeFileContents(…) ~/modules/system/traits/ViewMaker.php   97
47  Backend\Classes\ControllerBehavior->makePartial(…)  ~/modules/backend/behaviors/ListController.php  393
46  Backend\Behaviors\ListController->listMakePartial(…)     ~/modules/backend/behaviors/ListController.php 380
45  Backend\Behaviors\ListController->listRender()      
44  call_user_func_array(…) ~/vendor/october/rain/src/Extension/ExtendableTrait.php 397
43  October\Rain\Extension\Extendable->extendableCall(…)    ~/vendor/october/rain/src/Extension/Extendable.php  46
42  October\Rain\Extension\Extendable->__call(…)    ~/plugins/lss/eatology/controllers/customerdata/index.htm   1
41  include(…)  ~/modules/system/traits/ViewMaker.php   247
40  Backend\Classes\Controller->makeFileContents(…) ~/modules/system/traits/ViewMaker.php   109
39  Backend\Classes\Controller->makeView(…) ~/modules/backend/classes/Controller.php    390
38  Backend\Classes\Controller->execPageAction(…)   ~/modules/backend/classes/Controller.php    272
37  Backend\Classes\Controller->run(…)  ~/modules/backend/classes/BackendController.php 120
36  Backend\Classes\BackendController->run(…)       
35  call_user_func_array(…) ~/vendor/laravel/framework/src/Illuminate/Routing/Controller.php    54
34  Illuminate\Routing\Controller->callAction(…)    ~/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php  45
33  Illuminate\Routing\ControllerDispatcher->dispatch(…)    ~/vendor/laravel/framework/src/Illuminate/Routing/Route.php 212
32  Illuminate\Routing\Route->runController()   ~/vendor/laravel/framework/src/Illuminate/Routing/Route.php 169
31  Illuminate\Routing\Route->run() ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php    658
30  Illuminate\Routing\Router->Illuminate\Routing\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  30
29  Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php 41
28  Illuminate\Routing\Middleware\SubstituteBindings->handle(…) ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 149
27  Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  53
26  Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php    49
25  Illuminate\View\Middleware\ShareErrorsFromSession->handle(…)    ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 149
24  Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  53
23  Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php   63
22  Illuminate\Session\Middleware\StartSession->handle(…)   ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 149
21  Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  53
20  Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php  37
19  Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(…)  ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 149
18  Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  53
17  Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php  66
16  Illuminate\Cookie\Middleware\EncryptCookies->handle(…)  ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 149
15  Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  53
14  Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 102
13  Illuminate\Pipeline\Pipeline->then(…)   ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php    660
12  Illuminate\Routing\Router->runRouteWithinStack(…)   ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php    635
11  Illuminate\Routing\Router->runRoute(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php    601
10  Illuminate\Routing\Router->dispatchToRoute(…)   ~/vendor/october/rain/src/Router/CoreRouter.php 20
9   October\Rain\Router\CoreRouter->dispatch(…) ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php    176
8   Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  30
7   Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php    46
6   Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(…)    ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 149
5   Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)  ~/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php  53
4   Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(…)    ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php 102
3   Illuminate\Pipeline\Pipeline->then(…)   ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php    151
2   Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(…)  ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php    116
1   Illuminate\Foundation\Http\Kernel->handle(…)    ~/index.php 44