[英]Why do I get array to string conversion error?
I have the following two SQL queries the first one looks up the partner_id
in a table called orders
, the second one changes the partner name using the partner_id
but I get the error "array to string conversion".我有以下两个 SQL 查询,第一个查询在名为orders
的表中查找partner_id
,第二个查询使用partner_id
更改合作伙伴名称,但我收到错误“数组到字符串转换”。
How to set partner_id
to be an integer?如何将partner_id
设置为 integer?
$partner_id_ = DB::select('select partner_id from orders where id = ? ', [$id]);
DB::update('update partners set name = ? where id =?',[$partner,$partner_id_]);
$partner_id_ = DB::select('select partner_id from orders where id = ? ', [$id]);
Defines $partner_id_
as an array with 1 element of stdClass with single property partner_id
.将$partner_id_
定义为一个数组,其中包含 stdClass 的 1 个元素和单个属性partner_id
。
If you are sure that you will always find at least one row there, change $partner_id_
to $partner_id_[0]->partner_id
in the following line:如果您确定总能在那里找到至少一行,请在以下行中将 $ $partner_id_
更改为$partner_id_[0]->partner_id
:
DB::update('update partners set name = ? where id =?',[$partner,$partner_id_[0]->partner_id]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.