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


PHP Sanitize::saveDb方法代碼示例

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


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

示例1: save

 public static function save($value, $type, $standard = null)
 {
     $var = $standard;
     if ($value !== null) {
         if ($type == VAR_DB || $type == VAR_ARR_DB) {
             $var = Sanitize::saveDb($value);
         } elseif ($type == VAR_HTML || $type == VAR_ARR_HTML) {
             $var = Sanitize::saveHTML($value);
         } elseif ($type == VAR_INT || $type == VAR_ARR_INT) {
             $var = Sanitize::saveInt($value);
         } elseif ($type == VAR_ALNUM || $type == VAR_ARR_ALNUM) {
             $var = Sanitize::saveAlNum($value, true);
         } elseif ($type == VAR_URI || $type == VAR_ARR_URI) {
             $var = Sanitize::saveAlNum($value, false);
         } else {
             $var = Sanitize::removeNullByte($value);
         }
     } else {
         if ($standard === null) {
             if ($type == VAR_DB || $type == VAR_ALNUM || $type == VAR_HTML || $type == VAR_URI) {
                 $var = '';
             } elseif ($type == VAR_INT) {
                 $var = 0;
             } elseif ($type == VAR_ARR_INT || $type == VAR_ARR_DB || $type == VAR_ARR_ALNUM || $type == VAR_ARR_NONE || $type == VAR_ARR_HTML || $type == VAR_ARR_URI) {
                 $var = array();
             } else {
                 $var = null;
             }
         }
     }
     return $var;
 }
開發者ID:BackupTheBerlios,項目名稱:viscacha-svn,代碼行數:32,代碼來源:class.Sanitize.php

示例2: getAverageFields

 public static function getAverageFields(CustomDataPosition $pos, array $params = array())
 {
     $filter = new CustomDataFilter($pos);
     $filter->field(null);
     $fields = $pos->getFieldsForClassPath(self::$classPath);
     foreach ($fields as $field) {
         $fieldName = Sanitize::saveDb($field->getFieldName());
         $filter->fieldCalculation($fieldName, "AVG({$fieldName})");
     }
     foreach ($params as $field => $value) {
         $filter->condition($field, $value);
     }
     $result = $filter->execute();
     if ($result) {
         $data = new CustomData($pos);
         $row = Database::getObject()->fetchAssoc($result);
         if ($row) {
             $data = new CustomData($pos);
             $data->set($row, true, $fields);
             return $data->getFields(array_keys($fields));
         }
     }
     return array();
 }
開發者ID:BackupTheBerlios,項目名稱:viscacha-svn,代碼行數:24,代碼來源:class.CustomRating.php


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