当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_Type::escapeAll方法代码示例

本文整理汇总了PHP中CRM_Utils_Type::escapeAll方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Type::escapeAll方法的具体用法?PHP CRM_Utils_Type::escapeAll怎么用?PHP CRM_Utils_Type::escapeAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Type的用法示例。


在下文中一共展示了CRM_Utils_Type::escapeAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: toggleDedupeSelect

 /**
  * Mark dupe pairs as selected from un-selected state or vice-versa, in dupe cache table.
  */
 public static function toggleDedupeSelect()
 {
     $rgid = CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer');
     $gid = CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer');
     $pnid = $_REQUEST['pnid'];
     $isSelected = CRM_Utils_Type::escape($_REQUEST['is_selected'], 'Boolean');
     $cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid);
     $params = array(1 => array($isSelected, 'Boolean'), 3 => array("{$cacheKeyString}%", 'String'));
     //check pnid is_array or integer
     $whereClause = NULL;
     if (is_array($pnid) && !CRM_Utils_Array::crmIsEmptyArray($pnid)) {
         CRM_Utils_Type::escapeAll($pnid, 'Positive');
         $pnid = implode(', ', $pnid);
         $whereClause = " id IN ( {$pnid} ) ";
     } else {
         $pnid = CRM_Utils_Type::escape($pnid, 'Integer');
         $whereClause = " id = %2";
         $params[2] = array($pnid, 'Integer');
     }
     $sql = "UPDATE civicrm_prevnext_cache SET is_selected = %1 WHERE {$whereClause} AND cacheKey LIKE %3";
     CRM_Core_DAO::executeQuery($sql, $params);
     CRM_Utils_System::civiExit();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:26,代码来源:AJAX.php

示例2: whereClause

 /**
  * Generate where clause.
  *
  * This can be overridden in reports for special treatment of a field
  *
  * @param array $field Field specifications
  * @param string $op Query operator (not an exact match to sql)
  * @param mixed $value
  * @param float $min
  * @param float $max
  *
  * @return null|string
  */
 public function whereClause(&$field, $op, $value, $min, $max)
 {
     $type = CRM_Utils_Type::typeToString(CRM_Utils_Array::value('type', $field));
     $clause = NULL;
     switch ($op) {
         case 'bw':
         case 'nbw':
             if ($min !== NULL && strlen($min) > 0 || $max !== NULL && strlen($max) > 0) {
                 $min = CRM_Utils_Type::escape($min, $type);
                 $max = CRM_Utils_Type::escape($max, $type);
                 $clauses = array();
                 if ($min) {
                     if ($op == 'bw') {
                         $clauses[] = "( {$field['dbAlias']} >= {$min} )";
                     } else {
                         $clauses[] = "( {$field['dbAlias']} < {$min} )";
                     }
                 }
                 if ($max) {
                     if ($op == 'bw') {
                         $clauses[] = "( {$field['dbAlias']} <= {$max} )";
                     } else {
                         $clauses[] = "( {$field['dbAlias']} > {$max} )";
                     }
                 }
                 if (!empty($clauses)) {
                     if ($op == 'bw') {
                         $clause = implode(' AND ', $clauses);
                     } else {
                         $clause = implode(' OR ', $clauses);
                     }
                 }
             }
             break;
         case 'has':
         case 'nhas':
             if ($value !== NULL && strlen($value) > 0) {
                 $value = CRM_Utils_Type::escape($value, $type);
                 if (strpos($value, '%') === FALSE) {
                     $value = "'%{$value}%'";
                 } else {
                     $value = "'{$value}'";
                 }
                 $sqlOP = $this->getSQLOperator($op);
                 $clause = "( {$field['dbAlias']} {$sqlOP} {$value} )";
             }
             break;
         case 'in':
         case 'notin':
             if (is_string($value) && strlen($value)) {
                 $value = explode(',', $value);
             }
             if ($value !== NULL && is_array($value) && count($value) > 0) {
                 $sqlOP = $this->getSQLOperator($op);
                 if (CRM_Utils_Array::value('type', $field) == CRM_Utils_Type::T_STRING) {
                     //cycle through selections and escape values
                     foreach ($value as $key => $selection) {
                         $value[$key] = CRM_Utils_Type::escape($selection, $type);
                     }
                     $clause = "( {$field['dbAlias']} {$sqlOP} ( '" . implode("' , '", $value) . "') )";
                 } else {
                     // for numerical values
                     $clause = "{$field['dbAlias']} {$sqlOP} (" . implode(', ', $value) . ")";
                 }
                 if ($op == 'notin') {
                     $clause = "( " . $clause . " OR {$field['dbAlias']} IS NULL )";
                 } else {
                     $clause = "( " . $clause . " )";
                 }
             }
             break;
         case 'mhas':
         case 'mnot':
             // multiple has or multiple not
             if ($value !== NULL && count($value) > 0) {
                 $value = CRM_Utils_Type::escapeAll($value, $type);
                 $operator = $op == 'mnot' ? 'NOT' : '';
                 $regexp = "[[:cntrl:]]*" . implode('[[:>:]]*|[[:<:]]*', (array) $value) . "[[:cntrl:]]*";
                 $clause = "{$field['dbAlias']} {$operator} REGEXP '{$regexp}'";
             }
             break;
         case 'sw':
         case 'ew':
             if ($value !== NULL && strlen($value) > 0) {
                 $value = CRM_Utils_Type::escape($value, $type);
                 if (strpos($value, '%') === FALSE) {
                     if ($op == 'sw') {
//.........这里部分代码省略.........
开发者ID:konadave,项目名称:civicrm-core,代码行数:101,代码来源:Form.php


注:本文中的CRM_Utils_Type::escapeAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。