SQLSTATE[HY000]: General error: 1364 Field 'trans_id' doesn't have a default value
SQLSTATE[HY000]: General error: 1364 Field 'trans_id' doesn't have a default value
我在尝试完成 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))
Connection.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:插入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, 您的交易描述, 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
有人可以解释并帮助我为什么它不起作用吗?
对于 mass 赋值,您需要在 Transction
模型上定义 fillable
属性 :
protected $fillable = ['trans_id','amount','sender','type','currency','description','fee','client_id','status','receiver'];
我在尝试完成 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))
Connection.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:插入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, 您的交易描述, 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
有人可以解释并帮助我为什么它不起作用吗?
对于 mass 赋值,您需要在 Transction
模型上定义 fillable
属性 :
protected $fillable = ['trans_id','amount','sender','type','currency','description','fee','client_id','status','receiver'];