I'm getting a lot of product information from the Cosmos API and storing it into variables, but how do I save the information from those 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 the $ nameprdt and $ segmentation to the database.
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);
}