本文整理汇总了PHP中DataHandler::forceNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP DataHandler::forceNumber方法的具体用法?PHP DataHandler::forceNumber怎么用?PHP DataHandler::forceNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataHandler
的用法示例。
在下文中一共展示了DataHandler::forceNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setNumber
/**
* @param $number (number)
* @return void
*/
public function setNumber($number)
{
if ($number !== NULL) {
$this->number = DataHandler::forceNumber($number);
}
}
示例2: forceType
static function forceType($valor, $type = "string")
{
switch ($type) {
case "string":
case "date":
return DataHandler::forceString($valor);
break;
case "number":
return DataHandler::forceNumber($valor);
break;
case "int":
return DataHandler::forceInt($valor);
break;
default:
return DataHandler::forceString($valor);
break;
}
}
示例3: update
/**
* @param $table
* @param $table_id
* @param $name
* @param $type
* @param $active
* @param $locale
* @param $varchar
* @param $text
* @param $number
* @param $int
* @param $date
* @return ReturnDataVO
*/
public function update($id, $table, $table_id, $name = NULL, $type = ParametherDAO::TYPE_VARCHAR, $active = 1, $locale = NULL, $varchar = NULL, $text = NULL, $number = NULL, $int = NULL, $date = NULL)
{
$ReturnDataVO = new ReturnDataVO();
if ($id == NULL && $id <= 0) {
$ReturnDataVO->success = FALSE;
$ReturnDataVO->code_return = DbInterface::ERROR_PARAMETHER_UPDATE_DONOT_HAVE_ID;
return $ReturnDataVO;
}
$query = "UPDATE `paramether` SET ";
$comma = "";
if ($active !== NULL) {
$query .= "{$comma} `active` = '" . DataHandler::forceInt($active) . "'";
$comma = ", ";
}
if ($table !== NULL) {
$query .= " {$comma} `table` = '" . DataHandler::forceString($table) . "'";
$comma = " , ";
}
if ($table_id !== NULL) {
$query .= " {$comma} `table_id` = '" . DataHandler::forceInt($table_id) . "'";
$comma = " , ";
}
if ($name !== NULL) {
$query .= "{$comma} `name` = '" . DataHandler::forceString($name) . "'";
$comma = ", ";
}
if ($type !== NULL) {
$query .= " {$comma} `type` = '" . DataHandler::forceString($type) . "'";
$comma = " , ";
}
if ($locale !== NULL) {
$query .= " {$comma} `locale` = '" . DataHandler::forceString($locale) . "'";
$comma = ", ";
}
if ($varchar !== NULL) {
$query .= " {$comma} `varchar` = '" . DataHandler::forceString($varchar) . "'";
$comma = ", ";
}
if ($text !== NULL) {
$query .= " {$comma} `text` = '" . DataHandler::forceString($text) . "'";
$comma = ", ";
}
if ($number !== NULL) {
$query .= " {$comma} `number` = '" . DataHandler::forceNumber($number) . "'";
$comma = ", ";
}
if ($int !== NULL) {
$query .= " {$comma} `int` = '" . DataHandler::forceInt($int) . "'";
$comma = ", ";
}
if ($date !== NULL) {
$query .= " {$comma} `date` = '" . DataHandler::convertDateToDB($date) . "'";
$comma = ", ";
}
$query .= " WHERE id = '" . DataHandler::forceInt($id) . "' LIMIT 1 ";
//echo $query;
if ($comma == "") {
$ReturnDataVO->success = FALSE;
$ReturnDataVO->code_return = DbInterface::ERROR_PARAMETHER_UPDATE_DONOT_HAVE_UPDATES;
return $ReturnDataVO;
} else {
$ReturnDataVO = parent::query($query);
if (!$ReturnDataVO->success) {
$ReturnDataVO->code_return = DbInterface::ERROR_PARAMETHER_UPDATE_COMMIT;
}
return $ReturnDataVO;
}
}
示例4: purchaseDetail
public function purchaseDetail()
{
//iniciando o retorno padrao em http result
$returnResult = new HttpResult();
//id do pedido
$id_purchase_order = DataHandler::forceInt($this->arrayRestFolder[1]);
//agora verifica se esse pedido é desse usuário
$eh_desse_cara = $this->checkPurchaseOwner($id_purchase_order, UserClient::getId());
if ($eh_desse_cara) {
//o pedido é dele
//busca o detalhe dos pedidos
$VO = new PurchaseOrderVO();
$VO->setId($id_purchase_order, TRUE);
$StdVO = $VO->toStdClass();
$returnResult->setSuccess(TRUE);
$retornoDaPaginaHTML = new PurchaseInfo();
//lista os pagamentos efetuados pra esse id
//$StdVO->id
include_once "library/e_commerce/modules/payment/dao/PaymentDAO.class.php";
$PaymentDAO = PaymentDAO::getInstance();
$ReturnResultVO = $PaymentDAO->select(PaymentDAO::RETURN_VO, NULL, 1, NULL, $StdVO->id);
$ReturnResultVO->transformAllVoInStdClass();
//~inventa um parametro
$StdVO->array_payment = array();
$StdVO->total_payment = 0;
if ($ReturnResultVO->success) {
$StdVO->array_payment = $ReturnResultVO->result;
foreach ($StdVO->array_payment as $StdPaymentVO) {
$StdVO->total_payment += DataHandler::forceNumber($StdPaymentVO->total_value);
}
}
$StdVO->total_payment = DataHandler::convertMoneyToBrazil($StdVO->total_payment, FALSE);
$StdVO->total_a_pagar = 0;
$tempDebito = DataHandler::forceNumber($StdVO->total_value) - DataHandler::forceNumber($StdVO->total_payment);
if ($tempDebito > 0) {
$StdVO->total_a_pagar = $tempDebito;
}
$StdVO->total_a_pagar = DataHandler::convertMoneyToBrazil($StdVO->total_a_pagar, FALSE);
include_once "library/e_commerce/modules/purchase/dao/PurchaseItemDAO.class.php";
$PurchaseItemDAO = PurchaseItemDAO::getInstance();
/*
*
*/
$ReturnDataVO = $PurchaseItemDAO->select(PurchaseItemDAO::RETURN_VO, NULL, NULL, $StdVO->id);
$ReturnDataVO->transformAllVoInStdClass();
//~inventa um parametro
$StdVO->array_itens = array();
if ($ReturnDataVO->success) {
$StdVO->array_itens = $ReturnDataVO->result;
}
$valorSomandoItens = 0;
foreach ($StdVO->array_itens as $item) {
$valorSomandoItens = $valorSomandoItens + DataHandler::forceNumber($item->product_price) * $item->quantity;
}
$descontoFinal = 0;
$CouponVO = new CouponVO();
$arrayLinkVO = $VO->getLinks("coupon", 1);
if (count($arrayLinkVO) > 0) {
//busca todos os cupons dentro da validade e que o codigo token não é obrigatorio
$CouponDAO = CouponDAO::getInstance();
$ReturnDataVO = $CouponDAO->select(CouponDAO::RETURN_VO, $arrayLinkVO[0]->linked_table_id, 2, NULL, NULL, NULL, NULL, NULL, date('Y-m-d'), $date_in_symbol = "<=", date('Y-m-d'), $date_out_symbol = ">=");
if ($ReturnDataVO->success && count($ReturnDataVO->result) > 0) {
$CouponVO = $ReturnDataVO->result[0];
switch ($CouponVO->getType()) {
case "+":
$descontoFinal = $CouponVO->getValue() + $valorSomandoItens;
break;
case "-":
$descontoFinal = $CouponVO->getValue() - $valorSomandoItens;
break;
case "*":
$descontoFinal = $valorSomandoItens - $valorSomandoItens * ($CouponVO->getValue() / 100);
break;
default:
break;
}
}
}
$CouponStd = $CouponVO->toStdClass();
$CouponStd->valor_total = $valorSomandoItens;
$CouponStd->valor_desconto = $valorSomandoItens - $descontoFinal;
$StdVO->coupon = $CouponStd;
$retornoDaPaginaHTML->std_vo = $StdVO;
$returnResult->setHttpContentResult($retornoDaPaginaHTML);
} else {
$returnResult->setSuccess(FALSE);
$returnResult->addMessage("Não foi encontrado o detalhe desse pedido.");
}
//retorna pra view
return $returnResult;
}