I use the following query through php:
<?php
$this->db->query("INSERT INTO order` SET custom_field = '"
. $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '')
. "', payment_company_id = '" . $firstvalue[1]
. "', payment_tax_id = '" . $secondvaluein . ");
?>
The insertion in custom_field column is done normally and i need to use its value splitted to put it in payment_company_id and payment_tax_id columns.
Data saved in custom_field are like this:
{"1":"value of first custom field","2":"value of second custom field"}
I used the following code before my script:
<?php
$myfinalfield = $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '');
$array = explode('","', $myfinalfield);
$firstvalue = explode(':"', $array[0]);
$secondvalue = explode(':"', $array[1]);
$secondvaluein = str_replace('"}','', $secondvalue[1]);
?>
in order to use $firstvalue[1] and $secondvaluein to the insert as you see to the first query above, but my columns are filled with nothing. Any ideas on this?
P.S. Also if i type greek characters then even in custom_field column even if its collation is utf8_general_ci i getn wrong encoding.
Thank you in advance