首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel - Wampserver64 - SQLSTATE[01000]:警告:第1行“区”列的1265个数据被截断

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

Stack Overflow用户
提问于 2019-07-08 02:45:40
回答 1查看 965关注 0票数 0

我正在修改在Wampserver上创建的WebApp。我想在页面CustomerData/Create.中添加一些选项,比如一个名为‘some’的下拉列表

在fields.yaml上添加代码之后:

代码语言:javascript
复制
    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工作台上,我加入“分区”为ENUM(“九龙”、“中环”、“北角”、“鱼涌”、“太古城”、“天后”、“湾仔”、“跑马地”、“西营盘”、“中层”、“上环”、“薄扶林”、“金钟”、“坚地城”、“鸭洲”、“山顶”、“黄竹坑”、“新界”、“铜锣湾”)。

然而,我有以下错误:

SQL 010000:警告:125个数据被截断,列‘区’在第1行(SQL:插入.在C:\wamp64...\Database\Connection.php的第664行)

下面是第664行的Connection.php代码:

代码语言:javascript
复制
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;
}

如何修复此错误?

EN

回答 1

Stack Overflow用户

发布于 2019-07-08 03:19:52

当插入未被具体枚举的ENUM值时,您将得到Data truncated for column...错误(如在创建列时插入的特定ENUM选项之一)。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56927808

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档