0

I have this variable which I want to insert to the database. Basically I want to insert array of objects:

$data['matching_competitors'] = [
    [
        'id_project'            =>  $id_project, 
        'id_product'            =>  $product_id, 
        'link'                  =>  $link, 
        'id_product_competitor' =>  $id_competitor, 
        'link_competitor'       =>  ''
    ], 
    [
        'id_project'            =>  $id_project, 
        'id_product'            =>  $product_id, 
        'link'                  =>  $link, 
        'id_product_competitor' =>  $id_competitor, 
        'link_competitor'       =>  ''
    ], 
    
];

$insert_matching = DB::connection( $db_name )
                ->table( $db_name . '.product_matching')
                ->insert( $data );

but I got an error:

"Array to string conversion"

Shibbir
  • 1,963
  • 2
  • 25
  • 48

0 Answers0