コード例 #1
0
ファイル: NPLib_String.php プロジェクト: dpecos/npshop
function NP_set_i18n($strings, $val = null, $lang = null)
{
    if (is_string($strings)) {
        $tmp = NP_DDBB::decodeI18NSqlValue($strings);
        if (is_array($tmp)) {
            $strings = $tmp;
        }
    } else {
        if (is_null($strings)) {
            $strings = array();
        }
    }
    if (is_array($strings)) {
        if ($val === null && $lang !== null) {
            unset($strings[$lang]);
        } else {
            if ($lang === null) {
                $strings[NP_LANG] = $val;
            } else {
                $strings[$lang] = $val;
            }
        }
        return $strings;
    } else {
        if (!is_null($strings)) {
            return $strings;
        } else {
            return $val;
        }
    }
}
コード例 #2
0
ファイル: NPLib_Sql_2.php プロジェクト: dpecos/npshop
 function decodeSQLValue($strVal, $sqlType)
 {
     if (isset($strVal) && $strVal !== null) {
         if ($sqlType == "STRING" || $sqlType == "TEXT") {
             return $strVal;
         } else {
             if ($sqlType == "STRING_I18N" || $sqlType == "TEXT_I18N") {
                 return NP_DDBB::decodeI18NSqlValue($strVal);
             } else {
                 if ($sqlType == "BOOL") {
                     if (isset($strVal) && $strVal != "") {
                         return $strVal == "1";
                     } else {
                         return false;
                     }
                 } else {
                     if ($sqlType == "INT") {
                         if (isset($strVal) && $strVal != "") {
                             return intval($strVal);
                         } else {
                             return 0;
                         }
                     } else {
                         if ($sqlType == "FLOAT") {
                             if (isset($strVal) && $strVal != "") {
                                 return number_format((double) $strVal, 2, '.', '');
                             } else {
                                 return 0;
                             }
                         } else {
                             if ($sqlType == "DATE") {
                                 if (isset($strVal) && $strVal != "") {
                                     return date($strVal);
                                 } else {
                                     return null;
                                 }
                             } else {
                                 return $strVal;
                             }
                         }
                     }
                 }
             }
         }
     } else {
         return null;
     }
 }