【发布时间】:2021-05-23 02:32:51
【问题描述】:
我在尝试从 payPal 完成付款处理时收到此错误:
SQLSTATE[HY000]:一般错误:1364 字段“trans_id”没有默认值(SQL:插入
transactions(amount、sender、type、currency,description,fee,client_id,status,receiver,updated_at,created_at) 值 (1.00, sb-9gnps5116369@personal.example.com, paypal, USD, 您的交易描述, 0, 1, 已批准, 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) 值 (1.00, sb-9gnps5116369@personal.example.com, , 您的交易描述, 0, 1, 已批准, 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
有人可以解释并帮助我为什么它不起作用吗?
【问题讨论】:
-
您是否在
fillable属性上添加了trans_id? -
你能指导我如何在可填充属性上添加 trans_id 吗?因为我是 Laravel 的新手@user15070659
-
添加您的模型数据
-
如果您的
trans_id是您的表primary_keyid,则设为autoincerment -
我只是把它们放在一起:protected $fillable = [ 'names', 'email','contact', 'password','secret_key','trans_id','amount' ,'sender','type','currency','description','fee','client_id','status','receiver',]; 我放在Client.php上,因为我发现那里有许多具有可填充属性的脚本,但我仍然遇到同样的错误,或者人们通常把它放在哪里?我的意思是,我好像没有模型数据文件夹,我不知道
标签: php mysql sql laravel paypal