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".
How to set partner_id
to be an 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
.
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:
DB::update('update partners set name = ? where id =?',[$partner,$partner_id_[0]->partner_id]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.