0
I’m getting a lot of product information from the Cosmos API and storing it in variables, but how do I save the information from these variables in the database?
VIEW
 $curl = curl_init($url);
 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($curl, CURLOPT_FAILONERROR, true);
 $data = curl_exec($curl);
 if ($data === false || $data == NULL) {
     var_dump(curl_error($curl));
 } else {
     $array = json_decode($data);
     $linkimg = $array->thumbnail;
     $nomeprdt = $array->description;
     $segmentacao = $array->ncm->description;
I wanted to pass to the database the $nomeprdt and $segmentation.
MODEL
    public function uploadtest($id,$nomeprdt,$segmentacao)
    {
      if($id > 0){
        $this->db->query("INSERT INTO produto(nomeprdt, segprdt) VALUES(? , ?)",$nomeprdt,$segmentacao);
      }else
      {
        return false;
      }
    }
CONTROLLER
public function upload_dcr(){
  $this->Produto_model->uploadtest($id,$nomeprdt,$segmentacao);
}
						
Have you tried using data of type JSON in creating the table
produto? Or alternatively, why not useserializeof PHP.– user38561
Which error is shown?
– tkmtts