예제 #1
0
 /**
  * @param mixed $mValue
  * @param string $sType
  */
 protected function setType(&$mValue, $sType)
 {
     $sType = strtolower($sType);
     if (in_array($sType, array('string', 'int', 'bool', 'array'))) {
         settype($mValue, $sType);
     } else {
         if (in_array($sType, array('datetime'))) {
             settype($mValue, 'int');
         } else {
             if (in_array($sType, array('password'))) {
                 settype($mValue, 'string');
             } else {
                 if (0 === strpos($sType, 'string(')) {
                     settype($mValue, 'string');
                     if (0 < strlen($mValue)) {
                         $iSize = substr($sType, 7, -1);
                         if (is_numeric($iSize) && (int) $iSize < strlen($mValue)) {
                             // $mValue = substr($mValue, 0, (int) $iSize);
                             $mValue = api_Utils::Utf8Truncate($mValue, (int) $iSize);
                         }
                     }
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * @param string $sType
  */
 public function setType($sType)
 {
     $sType = strtolower($sType);
     if (in_array($sType, array('string', 'int', 'array'))) {
         settype($this->Value, $sType);
     } else {
         if (in_array($sType, array('bool'))) {
             $this->Value = (bool) $this->Value;
         } else {
             if (in_array($sType, array('encoded', 'datetime'))) {
                 settype($this->Value, 'string');
             } else {
                 if (0 === strpos($sType, 'string(')) {
                     settype($this->Value, 'string');
                     if (0 < strlen($this->Value)) {
                         $iSize = substr($sType, 7, -1);
                         if (is_numeric($iSize) && (int) $iSize < strlen($this->Value)) {
                             $this->Value = api_Utils::Utf8Truncate($this->Value, (int) $iSize);
                         }
                     }
                 }
             }
         }
     }
 }