我正在使用 CodeIgniter 的 Active Record,我的代码是:
$current_balance = $this->get_campaign_balance($click_report['campaign_id']);
$campaign_ledger = array(
'campaign_id' => $click_report['campaign_id'],
'description' => "Click Deduction from script",
'amount' => -1 * $click_report['advertiser_spend'],
'balance' => "" . $current_balance - $click_report['advertiser_spend'],
'meta_data' => $click_report['day'],
'timestamp' => time()
);
$this->db->insert('campaign_ledger', $campaign_ledger);
当我var_dump
得到$campaign_ledger
:
array(6) {
["campaign_id"]=>
string(3) "277"
["description"]=>
string(27) "Click Deduction from script"
["amount"]=>
float(-0.05)
["balance"]=>
float(89.95)
["meta_data"]=>
string(10) "2012-04-19"
["timestamp"]=>
int(1334881599)
}
但是当数据进入我的数据库时,这balance
是91.36800000000001
出于某种原因。那么断开连接是怎么回事呢?
编辑
更改为 后DECIMAL(10,4)
,我仍然得到91.3680
输出。