當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。