繁体   English   中英

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

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

我在尝试从 payPal 完成付款处理时收到此错误:

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))

连接.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
 */

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

有人可以解释并帮助我为什么它不起作用吗?

对于质量分配,您需要在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.

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