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


PHP CRM_Contact_BAO_ProximityQuery::where方法代码示例

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


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

示例1: civicrm_api3_contact_proximity

/**
 * Get contacts by proximity.
 *
 * @param array $params
 *
 * @return array
 * @throws Exception
 */
function civicrm_api3_contact_proximity($params)
{
    $latitude = CRM_Utils_Array::value('latitude', $params);
    $longitude = CRM_Utils_Array::value('longitude', $params);
    $distance = CRM_Utils_Array::value('distance', $params);
    $unit = CRM_Utils_Array::value('unit', $params);
    // check and ensure that lat/long and distance are floats
    if (!CRM_Utils_Rule::numeric($latitude) || !CRM_Utils_Rule::numeric($longitude) || !CRM_Utils_Rule::numeric($distance)) {
        throw new Exception(ts('Latitude, Longitude and Distance should exist and be numeric'));
    }
    if ($unit == "mile") {
        $conversionFactor = 1609.344;
    } else {
        $conversionFactor = 1000;
    }
    //Distance in meters
    $distance = $distance * $conversionFactor;
    $whereClause = CRM_Contact_BAO_ProximityQuery::where($latitude, $longitude, $distance);
    $query = "\nSELECT    civicrm_contact.id as contact_id,\n          civicrm_contact.display_name as display_name\nFROM      civicrm_contact\nLEFT JOIN civicrm_address ON civicrm_contact.id = civicrm_address.contact_id\nWHERE     {$whereClause}\n";
    $dao = CRM_Core_DAO::executeQuery($query);
    $contacts = array();
    while ($dao->fetch()) {
        $contacts[] = $dao->toArray();
    }
    return civicrm_api3_create_success($contacts, $params, 'Contact', 'get_by_location', $dao);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:34,代码来源:Contact.php

示例2: where

 /**
  * @param bool $includeContactIDs
  *
  * @return string
  */
 public function where($includeContactIDs = FALSE)
 {
     $params = array();
     $clause = array();
     $where = CRM_Contact_BAO_ProximityQuery::where($this->_latitude, $this->_longitude, $this->_distance, 'address');
     if ($this->_tag) {
         $where .= "\nAND t.tag_id = {$this->_tag}\n";
     }
     if ($this->_group) {
         $where .= "\nAND cgc.group_id = {$this->_group}\n ";
     }
     $where .= " AND contact_a.is_deleted != 1 ";
     return $this->whereClause($where, $params);
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:19,代码来源:Proximity.php

示例3: buildProximityWhere

 /**
  * Helper method to filter Projects by location.
  *
  * @param array $params
  *   <ol>
  *     <li>string city - optional. Not used in this function, just passed along for geocoding.</li>
  *     <li>mixed country - required if lat/lon not provided. Can be country_id or string.</li>
  *     <li>float lat - required if country not provided</li>
  *     <li>float lon - required if country not provided</li>
  *     <li>string postal_code - optional. Not used in this function, just passed along for geocoding.</li>
  *     <li>float radius - required</li>
  *     <li>string street_address - optional. Not used in this function, just passed along for geocoding.</li>
  *     <li>string unit - optional, defaults to meters unless 'mile' is specified</li>
  *   </ol>
  * @return string
  *   SQL fragment (partial where clause)
  * @throws Exception
  */
 private static function buildProximityWhere(array $params)
 {
     $country = $lat = $lon = $radius = $unit = NULL;
     extract($params, EXTR_IF_EXISTS);
     // ensure that radius is a float
     if (!CRM_Utils_Rule::numeric($radius)) {
         throw new Exception(ts('Radius should exist and be numeric'));
     }
     if (!CRM_Utils_Rule::numeric($lat) || !CRM_Utils_Rule::numeric($lon)) {
         if (empty($country)) {
             throw new Exception(ts('Either Country or both Latitude and Longitude are required'));
         }
         // TODO: I think CRM_Utils_Geocode_*::format should be responsible for this
         if (CRM_Utils_Type::validate($country, 'Positive', FALSE)) {
             $country = civicrm_api3('Country', 'getvalue', array('id' => $country, 'return' => 'name'));
         }
         // TODO: support other geocoders
         $geocodeSuccess = CRM_Utils_Geocode_Google::format($params);
         if (!$geocodeSuccess) {
             // this is intentionally a string; a query like "SELECT * FROM foo WHERE FALSE"
             // will return an empty set, which is what we should do if the provided address
             // can't be geocoded
             return 'FALSE';
         }
         // $params is passed to the geocoder by reference; on success, these values
         // will be available
         $lat = $params['geo_code_1'];
         $lon = $params['geo_code_2'];
     }
     $conversionFactor = $unit == "mile" ? 1609.344 : 1000;
     //radius in meters
     $radius = $radius * $conversionFactor;
     return CRM_Contact_BAO_ProximityQuery::where($lat, $lon, $radius);
 }
开发者ID:RussellAult,项目名称:org.civicrm.volunteer,代码行数:52,代码来源:Project.php

示例4: where

 function where($includeContactIDs = false)
 {
     $params = array();
     $clause = array();
     require_once 'CRM/Contact/BAO/ProximityQuery.php';
     $where = CRM_Contact_BAO_ProximityQuery::where($this->_latitude, $this->_longitude, $this->_distance, 'address');
     if ($this->_tag) {
         $where .= "\nAND t.tag_id = {$this->_tag}\n";
     }
     if ($this->_group) {
         $where .= "\nAND cgc.group_id = {$this->_group}\n ";
     }
     return $this->whereClause($where, $params);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:14,代码来源:Proximity.php


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