我有这个PHP函数:
**original content**
<html>
<body>
<!-- somthing text <a href="google.com" >google</a> somthing
asdf
asdfasdf
asdfasdfs
-->
<!-- somthing text <a href="google.com" >google</a> somthing
asdf<!--
asdfasdf
asdfasdfs
-->
<a href="yahoo.com">yahoo</a>
</body>
</html>
**Expected Content**
<html>
<body>
<!-- somthing text ^^ href="google.com" >google</a> somthing
asdf
asdfasdf
asdfasdfs
-->
<!-- somthing text ^^ href="google.com" >google</a> somthing
asdf<!--
asdfasdf ^^ href="google.com" >google</a>
asdfasdfs
-->
<a href="yahoo.com">yahoo</a>
</body>
</html>
当我执行public function addInvoice ($order_id, $invoice_id, $product_id, $product_quantity, $product_price, $product_reseller_fee,
$product_reseller_poin, $product_referral_fee, $product_referral_id,
$product_vendor_sales, $custom_invoice){
$this->connect();
$this->select('shopping_cart', 'courier_cost', NULL, 'product_id = "'.$product_id.'" AND order_id = "'.$order_id.'"', NULL, '1');
$ongkir = $this->getResult();
$ongkir = $ongkir[0]['courier_cost']; //-- this gives me ZERO when inserted into MySQL
$product_vendor_income = ($product_vendor_sales * $product_quantity) + $ongkir; //-- $ongkir in this formula also count as ZERO
$data = array ('order_id' => $this->escapeString($order_id),
'invoice_id' => $this->escapeString($invoice_id),
'product_id' => $this->escapeString($product_id),
'product_quantity' => $this->escapeString($product_quantity),
'product_price' => $this->escapeString($product_price),
'product_reseller_fee' => $this->escapeString($product_reseller_fee),
'product_reseller_poin' => $this->escapeString($product_reseller_poin),
'product_referral_fee' => $this->escapeString($product_referral_fee),
'product_referral_id' => $this->escapeString($product_referral_id),
'product_vendor_sales' => $this->escapeString($product_vendor_income),
'custom_invoice' => $this->escapeString($custom_invoice));
$this->insert('sales_invoice', $data);
$res = $this->getResult();
return $res;
}
时, $ongkir
变量结果为string(4) "6000"
。所以,我相信它是一个字符串。
另一方面,我有一个MySQL列,其数据类型为var_dump
。当我尝试将Decimal
插入数据库时,它最终为零。
我必须将此字符串转换为数字数据类型吗?这很奇怪......
我试图在屏幕上显示$ongkir
的价值:
$ongkir
它产生:
$ongkir = $product->addInvoiceCopy ('ORD - 5762 5CF0 BFB9 6', null, '801', '1', null, null, null, null, null, null, '22000', null);
$total = (100 * 2) + $ongkir;
var_dump($total);
所以,int(6200)
不是空变量或零。但为什么我插入MySQL时会得到零?任何线索?谢谢。