我在字符串中有数据数组(从 excel 导入)值。其中一项数据是会计数字,例如:9,999.99
该会计号码的我的 sql 数据类型是浮点数。每次我插入值时.. 它只存储 9 而不是 9,999.99 我计划以 9999.99 格式存储(不带逗号)
我无法将 sql 数据类型更改为字符串,因为它将用于稍后的计算.. 那么如何转换和存储数据?
感谢您的建议。谢谢
这是我插入数据库的代码
// To set HMS daily collection
function set_pbb_data($sheetDataPBB)
{
$OK = 0;
$notOK = 0;
$firstElement = true;
foreach ($sheetDataPBB as $value)
{
if ($firstElement) {
$firstElement = false;
}
else {
$dbEntry = array(
'sett_date' => $value[0],
'trans_date' => $value[1],
'card_no' => $value[2],
'card_type' => $value[3],
'trans_curr' => $value[4],
'trans_amt' => $value[5],
'sett_curr' => $value[6],
'sett_amt' => $value[7],
'gross_cur' => $value[8],
'gross_amt' => $value[9],
'mdr' => $value[10],
'mid' => $value[11],
'approval_code' => $value[12],
'status' => $value[13],
'tid' => $value[14],
'batch_no' => $value[15],
'dba' => $value[16],
'trace_no' => $value[17],
'prod_type' => $value[18]
);
if ($value[0] != null){
$this->db->insert('pbb_cc_tbl', $dbEntry);
if ($this->db->affected_rows() > 0) {
$OK++;
}
else {
echo '<script>alert(" '.$value[0].' Already Exist!");</script>';
$notOK++;
}
}
} //end-if
} //end-foreach
if ($this->db->affected_rows() > 0) {
echo '<script>alert("'.$OK.' PBB Data Added Successfully"); </script>';
}
else {
echo '<script>alert("'.$notOK.' PBB Data Already Exist!"); window.history.back();</script>';
}
}