本文整理汇总了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;
}
示例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();
}