PHP - Codeigniter removing dash and brackets while inserting to DB
So I've tried to debug this to some extend but I have no idea why this is
happening. So after retrieving info from and excel file I try to database,
for the most case this works, but I have 2 exceptions that are giving me a
hard time. Firstly a part no. with a "-" is removed while inserting (ex:
sxrv-11 becomes sxrv11) in the db and second brackets (ex: (pv) is
converted to a 1 so (pv)tr55x would become 1tr55x)
here is an example var_dump of the array:
array(20) {
["stock_no"]=>
float(127)
["part_no"]=>
string(9) "SIFR6A-11"
["pop_code"]=>
string(3) "D-N"
["jobber"]=>
float(15.2)
["sell_out"]=>
string(0) ""
["suggested_qty"]=>
float(4)
["box_qty"]=>
string(1) "1"
["case_qty"]=>
float(120)
["description"]=>
string(50) "LASER IRIDIUM SPARK PLUG / BOUGIE IRIDIUM AU LASER"
["individual_upc"]=>
string(12) "087295101278"
["box_upc"]=>
string(12) "087295001271"
["case_upc"]=>
string(14) "10087295001278"
["part_status"]=>
string(0) ""
["product_desc"]=>
string(0) ""
["box_size"]=>
string(0) ""
["fk_id_brand"]=>
int(1)
["fk_id_category"]=>
string(1) "1"
["fk_id_subcategory"]=>
string(1) "5"
["description_en"]=>
string(24) "laser iridium spark plug"
["description_fr"]=>
string(23) "bougie iridium au laser"
}
This is the insert function that uses that data array to insert:
public function insert_product($product)
{
echo "<pre>";
var_dump($product);
echo "</pre>";
$this->db->set('fk_id_category', $product['fk_id_category']);
$this->db->set('fk_id_subcategory', $product['fk_id_subcategory']);
$this->db->set('fk_id_brand', $product['fk_id_brand']);
$this->db->set('stock_no', $product['stock_no']);
$this->db->set('part_no', $product['part_no']);
$this->db->set('pop_code', $product['pop_code']);
$this->db->set('jobber', $product['jobber']);
$this->db->set('part_status', $product['part_status']);
$this->db->set('sell_out', $product['sell_out']);
$this->db->set('suggested_qty', $product['suggested_qty']);
$this->db->set('box_qty', $product['box_qty']);
$this->db->set('case_qty', $product['case_qty']);
$this->db->set('description_en', $product['description_en']);
$this->db->set('description_fr', $product['description_fr']);
$this->db->set('product_desc', $product['product_desc']);
$this->db->set('box_size', $product['box_size']);
$this->db->set('individual_upc', $product['individual_upc']);
$this->db->set('box_upc', $product['box_upc']);
$this->db->set('case_upc', $product['case_upc']);
$this->db->insert('product');
}
Once in the database it's modified to the examples described before. I've
tried different mysql collations and it doesn't change anything.
The oddest part about all this is that the "pop_code" keeps the "-" when
inserted in the database. They are both varchar() 20 and 5 respectively.
I can't tell if it's a PHP issue, codeigniter issue, mysql issue,
phpmyadmin issue. Does anyone have a clue?
No comments:
Post a Comment