0

我正在修改在 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 Valley', 《西营盘》、《半山》、《上环》、《薄扶林》、《金钟》、《坚尼地城》、《鸭脷洲》、《山顶》、《黄竹坑》、《新界》 ,'铜锣湾')。

不过,我有以下错误:

SQLSTATE[010000]:Warning:125 Data Truncated for column 'District' at row 1 (SQL: insert into ... on line 664 of 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;
}

如何修复此错误?

4

1 回答 1

0

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

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

于 2019-07-08T03:19:52.987 回答