Php SQLSTATE[HY000]:一般错误:1364字段';trans#u id';不';没有默认值
我在尝试从payPal完成付款处理时出错: SQLSTATE[HY000]:一般错误:1364字段“trans_id”没有默认值(SQL:insert-intoPhp SQLSTATE[HY000]:一般错误:1364字段';trans#u id';不';没有默认值,php,mysql,sql,laravel,paypal,Php,Mysql,Sql,Laravel,Paypal,我在尝试从payPal完成付款处理时出错: SQLSTATE[HY000]:一般错误:1364字段“trans_id”没有默认值(SQL:insert-intotransactions(金额,发送方,类型,货币,说明,费用,客户id,状态,接收方,更新,创建)值(1.00,某人)-9gnps5116369@personal.example.com,贝宝,美元,您的交易描述,0,1,已批准,sb-eftqj5115088@business.example.com,2021-02-19 23:11:
transactions
(金额
,发送方
,类型
,货币
,说明
,费用
,客户id
,状态
,接收方
,更新
,创建
)值(1.00,某人)-9gnps5116369@personal.example.com,贝宝,美元,您的交易描述,0,1,已批准,sb-eftqj5115088@business.example.com,2021-02-19 23:11:392021-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:insert-intotransactions
(金额
,发送方
,类型
,货币
,说明
,费用
,客户id
,状态
,接收方
,更新
,创建
)值(1.00,某人)-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
有人能解释一下为什么不起作用吗?对于作业,您需要在transaction
模型上定义filleble
属性:
protected $fillable = ['trans_id','amount','sender','type','currency','description','fee','client_id','status','receiver'];
对于分配,您需要在Transction
模型上定义filleble
属性:
protected $fillable = ['trans_id','amount','sender','type','currency','description','fee','client_id','status','receiver'];
你在
filleble
属性上添加了trans\u id
了吗?你能告诉我如何在filleble属性上添加trans\u id吗?因为我是Laravel@user15070659的新手,添加你的模型数据如果你的trans\u id
是你的表主键
id,请将其设置为自动确认
我只是将它们像:protected$filletabl一样放在一起e=[‘姓名’、‘电子邮件’、‘联系人’、‘密码’、‘密码’、‘交易id’、‘金额’、‘发件人’、‘类型’、‘货币’、‘说明’、‘费用’、‘客户id’、‘状态’、‘收件人’、];我把它放在Client.php上,因为我在那里发现了许多具有可填充属性的脚本,但我仍然得到了相同的错误,或者人们通常把它放在哪里?我的意思是,似乎我没有模型数据文件夹,我不知道你在可填充属性上添加了trans\u id
?你能指导我如何添加trans\u id吗关于可填充属性?因为我不熟悉Laravel@User15070659添加您的模型数据如果您的trans\u id
是您的表primary\u key
id,请将其设置为autoincrement
我只是将它们放在一起,如:protected$filleble=[‘姓名’、‘电子邮件’、‘联系人’、‘密码’、‘密码’、‘交易id’、‘金额’、‘发件人’、‘类型’、‘货币’、‘说明’、‘费用’、‘客户id’、‘状态’、‘收件人’、];我把它放在Client.php上,因为我在那里发现了许多具有fillable属性的脚本,但我仍然得到了相同的错误,或者人们通常将它放在哪里?我的意思是,似乎我没有模型数据文件夹,我不知道我只是将它们放在一起,比如:protected$fillable=[‘姓名’、‘电子邮件’、‘联系人’、‘密码’、‘密码’、‘交易id’、‘金额’、‘发件人’、‘类型’、‘货币’、‘说明’、‘费用’、‘客户id’、‘状态’、‘收件人’、];我把它放在Client.php上,因为我在那里发现了许多具有可填充属性的脚本,但我仍然得到了相同的错误,或者人们通常把它放在哪里?我的意思是,似乎我没有模型数据文件夹,我不知道你的查询,你是如何尝试在事务表上插入数据的?我只是将它们放在一起,就像:受保护的$fillable=['姓名','电子邮件','联系人','密码','密钥','交易id','金额','发件人','类型','货币','说明','费用','客户id','状态','接收人',];我把它放在Client.php上,因为我在那里发现了许多具有可填充属性的脚本,但我仍然得到了相同的错误,或者人们通常把它放在哪里?我的意思是,似乎我没有模型数据文件夹,我不知道您的查询,您是如何尝试在事务表中插入数据的?