简体   繁体   English

SQLSTATE [HY000]:一般错误:1364 字段“trans_id”没有默认值

[英]SQLSTATE[HY000]: General error: 1364 Field 'trans_id' doesn't have a default value

I got this error while I'm trying to finish the payment processing from payPal:我在尝试从 payPal 完成付款处理时收到此错误:

SQLSTATE[HY000]: General error: 1364 Field 'trans_id' doesn't have a default value (SQL: insert into transactions ( amount , sender , type , currency , description , fee , client_id , status , receiver , updated_at , created_at ) values (1.00, sb-9gnps5116369@personal.example.com, paypal, USD, Your transaction description, 0, 1, approved, sb-eftqj5115088@business.example.com, 2021-02-19 23:11:39, 2021-02-19 23:11:39)) SQLSTATE [HY000]:一般错误:1364 字段“trans_id”没有默认值(SQL:插入transactionsamountsendertypecurrencydescriptionfeeclient_idstatusreceiverupdated_atcreated_at )值(1.00, sb-9gnps5116369@personal.example.com, paypal, USD, Your transaction description, 0, 1, approved, sb-eftqj5115088@business.example.com, 2021-02-19 23:11:39, 2021- 02-19 23:11:39))

Connection.php:连接.php:

E:\laragon\www\thepaymentss\vendor\laravel\framework\src\Illuminate\Database\Connection.php

 * @param  array     $bindings
 * @param  \Closure  $callback
 * @return mixed
 *
 * @throws \Illuminate\Database\QueryException
 */
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;
}

/**
 * Log a query in the connection's query log.
 *
 * @param  string  $query
 * @param  array   $bindings
 * @param  float|null  $time
 * @return void
 */

The error of " SQLSTATE[HY000]: General error: 1364 Field 'trans_id' doesn't have a default value (SQL: insert into transactions ( amount , sender , type , currency , description , fee , client_id , status , receiver , updated_at , created_at ) values (1.00, sb-9gnps5116369@personal.example.com, paypal, USD, Your transaction description, 0, 1, approved, sb-eftqj5115088@business.example.com, 2021-02-19 23:11:39, 2021-02-19 23:11:39)) " is at line: SQLSTATE [HY000]的错误:一般错误:1364字段'trans_id'没有默认值(SQL:插入transactionsamountsendertypecurrencydescriptionfeeclient_idstatusreceiverupdated_at , created_at ) values (1.00, sb-9gnps5116369@personal.example.com, paypal, USD, Your transaction description, 0, 1, approved, sb-eftqj5115088@business.example.com, 2021-02-19 23:11: 39, 2021-02-19 23:11:39)) ”在行:

catch (Exception $e) {
        throw new QueryException(
            $query, $this->prepareBindings($bindings), $e

Can someone explain and help me why isn't it working?有人可以解释并帮助我为什么它不起作用吗?

For mass assignment, you need to define fillable property on Transction model:对于质量分配,您需要在Transction model 上定义fillable属性:

protected $fillable = ['trans_id','amount','sender','type','currency','description','fee','client_id','status','receiver'];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQLSTATE[HY000]:一般错误:1364 字段“country_id”没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'country_id' doesn't have a default value Laravel Voyager SQLSTATE [HY000]:常规错误:1364字段“ id”没有默认值 - Laravel Voyager SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value SQLSTATE[HY000]:一般错误:1364 字段“client_id”没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'client_id' doesn't have a default value SQLSTATE [HY000]:常规错误:1364字段'author_id'没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'author_id' doesn't have a default value Laravel SQLSTATE [HY000]:常规错误:1364字段“ id”没有默认值 - Laravel SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value SQLSTATE [HY000]:常规错误:1364字段“ reservation_id”没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'reservation_id' doesn't have a default value SQLSTATE [HY000]:常规错误:1364字段“ mov_id”没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'mov_id' doesn't have a default value SQLSTATE [HY000]:一般错误:1364 字段“agent_id”没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'agent_id' doesn't have a default value SQLSTATE[HY000]:一般错误:1364 字段“parent_id”没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'parent_id' doesn't have a default value SQLSTATE[HY000]:一般错误:1364 字段“已接受”没有默认值 - SQLSTATE[HY000]: General error: 1364 Field 'accepted' doesn't have a default value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM