I am trying to import data from commission junction to my database in MySQL. I succeeded to import the advertisers, but I still fail in importing the vouchers. The parameters who are making a problem are "postingDate", "promotion-end-date" and "promotion-start-date".
public function import()
{
$get_url = $this->get_response_by_url_voucher();
$xml = new SimpleXMLElement($get_url);
$json_string = json_encode($xml);
$getvoucher = json_decode($json_string, TRUE);
$this->import_voucher($getvoucher);
}
public function import_voucher($getvoucher = [])
{
if($getvoucher)
{
foreach($getvoucher['links']['link'] as $voucher)
{
$attr = [
'link-id' => $voucher['link-id'],
'advertiser-id' => $voucher['advertiser-id'],
'description' => $voucher['description'],
'coupon-code' => $voucher['coupon-code'],
'link-name' => $voucher['link-name'],
'promotion-type' => $voucher['promotion-type'],
'clickUrl' => $voucher['clickUrl'],
'promotion-start-date' => $voucher['promotion-start-date'],
'promotion-end-date' => $voucher['promotion-end-date'],
'relationship-status' => (int)$voucher['relationship-status'],
'language' => $voucher['language'],
];
$this->db->replace($this->table_voucher_name, $attr);
}
}
}
If I echo one of this three parameters I should get the dates for each voucher, but instead I get something like this:
ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray2018-04-16 19:47:00.0ArrayArrayArrayArrayArrayArray2018-04-22 16:00:00.02018-04-22 15:00:00.0Array2018-04-22 09:00:00.0ArrayArray2018-04-22 15:00:00.0ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray
Only some of the vouchers have dates, so there are only a few I can import this way to my database. What is wrong here?