當前位置: 首頁>>代碼示例>>PHP>>正文


PHP jDb::floatToStr方法代碼示例

本文整理匯總了PHP中jDb::floatToStr方法的典型用法代碼示例。如果您正苦於以下問題:PHP jDb::floatToStr方法的具體用法?PHP jDb::floatToStr怎麽用?PHP jDb::floatToStr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jDb的用法示例。


在下文中一共展示了jDb::floatToStr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testFloatToStr

 function testFloatToStr()
 {
     $this->assertEqual('12', jDb::floatToStr(12));
     $this->assertEqual('12.56', jDb::floatToStr(12.56));
     $this->assertEqual('12', jDb::floatToStr("12"));
     $this->assertEqual('12.56', jDb::floatToStr("12.56"));
     $this->assertEqual('65.78E6', jDb::floatToStr("65.78E6"));
     $this->assertEqual('65.78E6', jDb::floatToStr(65780000.0));
     $this->assertEqual('65.78E42', jDb::floatToStr(6.578E+43));
     // not very good behavior, but this is the behavior in old stable version of jelix
     $this->assertEqual('65', jDb::floatToStr("65,650.98"));
     $this->assertEqual('12', jDb::floatToStr("12,589"));
     // ',' no allowed as decimal separator
     $this->assertEqual('96', jDb::floatToStr("96 000,98"));
     // some test to detect if the behavior of PHP change
     $this->assertFalse(is_numeric("65,650.98"));
     $this->assertFalse(is_float("65,650.98"));
     $this->assertFalse(is_integer("65,650.98"));
     $this->assertEqual('65', floatval("65,650.98"));
 }
開發者ID:hadrienl,項目名稱:jelix,代碼行數:20,代碼來源:jdbtools.html_cli.php

示例2: _prepareValue

 /**
  * prepare the value ready to be used in a dynamic evaluation
  */
 protected final function _prepareValue($value, $fieldType, $notNull = false)
 {
     if (!$notNull && $value === null) {
         return 'NULL';
     }
     switch (strtolower($fieldType)) {
         case 'integer':
             return intval($value);
         case 'double':
         case 'float':
         case 'numeric':
         case 'decimal':
             return jDb::floatToStr($value);
         case 'boolean':
             if ($value === true || strtolower($value) == 'true' || intval($value) === 1 || $value === 't' || $value === 'on') {
                 return $this->trueValue;
             } else {
                 return $this->falseValue;
             }
             break;
         default:
             return $this->_conn->quote2($value, true, $fieldType == 'binary');
     }
 }
開發者ID:medali1990,項目名稱:medsite,代碼行數:27,代碼來源:jDaoFactoryBase.class.php

示例3: escapeValue

 public function escapeValue($unifiedType, $value, $checkNull = false, $toPhpSource = false)
 {
     if ($checkNull && ($value === null || strtolower($value) == 'null')) {
         return 'NULL';
     }
     switch ($this->unifiedToPHPType($unifiedType)) {
         case 'boolean':
             return $this->getBooleanValue($value);
         case 'integer':
             return (string) intval($value);
         case 'float':
         case 'numeric':
         case 'decimal':
             return jDb::floatToStr($value);
         default:
             if ($toPhpSource) {
                 if ($unifiedType == 'varbinary' || $unifiedType == 'binary') {
                     return '\'.$this->_conn->quote2(\'' . str_replace('\'', '\\\'', $value) . '\',true,true).\'';
                 } else {
                     if (strpos($value, "'") !== false) {
                         return '\'.$this->_conn->quote(\'' . str_replace('\'', '\\\'', $value) . '\').\'';
                     } else {
                         return "\\'" . $value . "\\'";
                     }
                 }
             } elseif ($this->_conn) {
                 return $this->_conn->quote($value);
             } else {
                 return "'" . addslashes($value) . "'";
             }
     }
 }
開發者ID:havefnubb,項目名稱:havefnubb,代碼行數:32,代碼來源:jDbTools.class.php


注:本文中的jDb::floatToStr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。