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


PHP CRM_Core_DAO_Address::save方法代码示例

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


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

示例1: processSharedAddress

 /**
  * Update the shared addresses if master address is modified.
  *
  * @param int $addressId
  *   Address id.
  * @param array $params
  *   Associated array of address params.
  */
 public static function processSharedAddress($addressId, $params)
 {
     $query = 'SELECT id FROM civicrm_address WHERE master_id = %1';
     $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($addressId, 'Integer')));
     // unset contact id
     $skipFields = array('is_primary', 'location_type_id', 'is_billing', 'master_id', 'contact_id');
     foreach ($skipFields as $value) {
         unset($params[$value]);
     }
     $addressDAO = new CRM_Core_DAO_Address();
     while ($dao->fetch()) {
         $addressDAO->copyValues($params);
         $addressDAO->id = $dao->id;
         $addressDAO->save();
         $addressDAO->free();
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:25,代码来源:Address.php

示例2: processContacts

function processContacts(&$config, $processGeocode, $parseStreetAddress, $start = null, $end = null)
{
    // build where clause.
    $clause = array('( c.id = a.contact_id )');
    if ($start) {
        $clause[] = "( c.id >= {$start} )";
    }
    if ($end) {
        $clause[] = "( c.id <= {$end} )";
    }
    if ($processGeocode) {
        $clause[] = '( a.geo_code_1 is null OR a.geo_code_1 = 0 )';
        $clause[] = '( a.geo_code_2 is null OR a.geo_code_2 = 0 )';
        $clause[] = '( a.country_id is not null )';
    }
    $whereClause = implode(' AND ', $clause);
    $query = "\nSELECT     c.id,\n           a.id as address_id,\n           a.street_address,\n           a.city,\n           a.postal_code,\n           s.name as state,\n           o.name as country\nFROM       civicrm_contact  c\nINNER JOIN civicrm_address        a ON a.contact_id = c.id\nLEFT  JOIN civicrm_country        o ON a.country_id = o.id\nLEFT  JOIN civicrm_state_province s ON a.state_province_id = s.id\nWHERE      {$whereClause}\n  ORDER BY a.id\n";
    $totalGeocoded = $totalAddresses = $totalAddressParsed = 0;
    $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
    if ($processGeocode) {
        require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php';
    }
    require_once 'CRM/Core/DAO/Address.php';
    require_once 'CRM/Core/BAO/Address.php';
    while ($dao->fetch()) {
        $totalAddresses++;
        $params = array('street_address' => $dao->street_address, 'postal_code' => $dao->postal_code, 'city' => $dao->city, 'state_province' => $dao->state, 'country' => $dao->country);
        $addressParams = array();
        // process geocode.
        if ($processGeocode) {
            // loop through the address removing more information
            // so we can get some geocode for a partial address
            // i.e. city -> state -> country
            $maxTries = 5;
            do {
                if (defined('THROTTLE_REQUESTS') && THROTTLE_REQUESTS) {
                    usleep(50000);
                }
                eval($config->geocodeMethod . '::format( $params, true );');
                array_shift($params);
                $maxTries--;
            } while (!isset($params['geo_code_1']) && $maxTries > 1);
            if (isset($params['geo_code_1'])) {
                $totalGeocoded++;
                $addressParams['geo_code_1'] = $params['geo_code_1'];
                $addressParams['geo_code_2'] = $params['geo_code_2'];
            }
        }
        // parse street address
        if ($parseStreetAddress) {
            $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($dao->street_address);
            $success = true;
            // consider address is automatically parseable,
            // when we should found street_number and street_name
            if (!CRM_Utils_Array::value('street_name', $parsedFields) || !CRM_Utils_Array::value('street_number', $parsedFields)) {
                $success = false;
            }
            // do check for all elements.
            if ($success) {
                $totalAddressParsed++;
            } else {
                // reset element values.
                $parsedFields = array_fill_keys(array_keys($parsedFields), '');
            }
            $addressParams = array_merge($addressParams, $parsedFields);
        }
        // finally update address object.
        if (!empty($addressParams)) {
            $address = new CRM_Core_DAO_Address();
            $address->id = $dao->address_id;
            $address->copyValues($addressParams);
            $address->save();
            $address->free();
        }
    }
    echo ts("Addresses Evaluated: {$totalAddresses}\n");
    if ($processGeocode) {
        echo ts("Addresses Geocoded : {$totalGeocoded}\n");
    }
    if ($parseStreetAddress) {
        echo ts("Street Address Parsed : {$totalAddressParsed}\n");
    }
    return;
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:84,代码来源:UpdateAddress.php

示例3: processContacts

/**
 * @param $config
 * @param $processGeocode
 * @param $parseStreetAddress
 * @param null $start
 * @param null $end
 */
function processContacts(&$config, $processGeocode, $parseStreetAddress, $start = NULL, $end = NULL)
{
    // build where clause.
    $clause = array('( c.id = a.contact_id )');
    if ($start) {
        $clause[] = "( c.id >= {$start} )";
    }
    if ($end) {
        $clause[] = "( c.id <= {$end} )";
    }
    if ($processGeocode) {
        $clause[] = '( a.geo_code_1 is null OR a.geo_code_1 = 0 )';
        $clause[] = '( a.geo_code_2 is null OR a.geo_code_2 = 0 )';
        $clause[] = '( a.country_id is not null )';
    }
    $whereClause = implode(' AND ', $clause);
    $query = "\nSELECT     c.id,\n           a.id as address_id,\n           a.street_address,\n           a.city,\n           a.postal_code,\n           s.name as state,\n           o.name as country\nFROM       civicrm_contact  c\nINNER JOIN civicrm_address        a ON a.contact_id = c.id\nLEFT  JOIN civicrm_country        o ON a.country_id = o.id\nLEFT  JOIN civicrm_state_province s ON a.state_province_id = s.id\nWHERE      {$whereClause}\n  ORDER BY a.id\n";
    $totalGeocoded = $totalAddresses = $totalAddressParsed = 0;
    $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
    if ($processGeocode) {
        require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php';
    }
    require_once 'CRM/Core/DAO/Address.php';
    require_once 'CRM/Core/BAO/Address.php';
    $unparseableContactAddress = array();
    while ($dao->fetch()) {
        $totalAddresses++;
        $params = array('street_address' => $dao->street_address, 'postal_code' => $dao->postal_code, 'city' => $dao->city, 'state_province' => $dao->state, 'country' => $dao->country);
        $addressParams = array();
        // process geocode.
        if ($processGeocode) {
            // loop through the address removing more information
            // so we can get some geocode for a partial address
            // i.e. city -> state -> country
            $maxTries = 5;
            do {
                if (defined('THROTTLE_REQUESTS') && THROTTLE_REQUESTS) {
                    usleep(50000);
                }
                eval($config->geocodeMethod . '::format( $params, true );');
                array_shift($params);
                $maxTries--;
            } while (!isset($params['geo_code_1']) && $maxTries > 1);
            if (isset($params['geo_code_1']) && $params['geo_code_1'] != 'null') {
                $totalGeocoded++;
                $addressParams['geo_code_1'] = $params['geo_code_1'];
                $addressParams['geo_code_2'] = $params['geo_code_2'];
            }
        }
        // parse street address
        if ($parseStreetAddress) {
            $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($dao->street_address);
            $success = TRUE;
            // consider address is automatically parseable,
            // when we should found street_number and street_name
            if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
                $success = FALSE;
            }
            // do check for all elements.
            if ($success) {
                $totalAddressParsed++;
            } elseif ($dao->street_address) {
                //build contact edit url,
                //so that user can manually fill the street address fields if the street address is not parsed, CRM-5886
                $url = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$dao->id}");
                $unparseableContactAddress[] = " Contact ID: " . $dao->id . " <a href =\"{$url}\"> " . $dao->street_address . " </a> ";
                // reset element values.
                $parsedFields = array_fill_keys(array_keys($parsedFields), '');
            }
            $addressParams = array_merge($addressParams, $parsedFields);
        }
        // finally update address object.
        if (!empty($addressParams)) {
            $address = new CRM_Core_DAO_Address();
            $address->id = $dao->address_id;
            $address->copyValues($addressParams);
            $address->save();
            $address->free();
        }
    }
    echo ts("Addresses Evaluated: {$totalAddresses}\n");
    if ($processGeocode) {
        echo ts("Addresses Geocoded : {$totalGeocoded}\n");
    }
    if ($parseStreetAddress) {
        echo ts("Street Address Parsed : {$totalAddressParsed}\n");
        if ($unparseableContactAddress) {
            echo ts("<br />\nFollowing is the list of contacts whose address is not parsed :<br />\n");
            foreach ($unparseableContactAddress as $contactLink) {
                echo ts("%1<br />\n", array(1 => $contactLink));
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:UpdateAddress.php

示例4: processContacts

 /**
  * @param $config
  * @param $processGeocode
  * @param $parseStreetAddress
  *
  * @return array
  * @throws Exception
  */
 public function processContacts(&$config, $processGeocode, $parseStreetAddress)
 {
     // build where clause.
     $clause = array('( c.id = a.contact_id )');
     $params = array();
     if ($this->start) {
         $clause[] = "( c.id >= %1 )";
         $params[1] = array($this->start, 'Integer');
     }
     if ($this->end) {
         $clause[] = "( c.id <= %2 )";
         $params[2] = array($this->end, 'Integer');
     }
     if ($processGeocode) {
         $clause[] = '( a.geo_code_1 is null OR a.geo_code_1 = 0 )';
         $clause[] = '( a.geo_code_2 is null OR a.geo_code_2 = 0 )';
         $clause[] = '( a.country_id is not null )';
     }
     $whereClause = implode(' AND ', $clause);
     $query = "\n    SELECT     c.id,\n               a.id as address_id,\n               a.street_address,\n               a.city,\n               a.postal_code,\n               s.name as state,\n               o.name as country\n    FROM       civicrm_contact  c\n    INNER JOIN civicrm_address        a ON a.contact_id = c.id\n    LEFT  JOIN civicrm_country        o ON a.country_id = o.id\n    LEFT  JOIN civicrm_state_province s ON a.state_province_id = s.id\n    WHERE      {$whereClause}\n      ORDER BY a.id\n    ";
     $totalGeocoded = $totalAddresses = $totalAddressParsed = 0;
     $dao = CRM_Core_DAO::executeQuery($query, $params);
     if ($processGeocode) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php';
     }
     $unparseableContactAddress = array();
     while ($dao->fetch()) {
         $totalAddresses++;
         $params = array('street_address' => $dao->street_address, 'postal_code' => $dao->postal_code, 'city' => $dao->city, 'state_province' => $dao->state, 'country' => $dao->country);
         $addressParams = array();
         // process geocode.
         if ($processGeocode) {
             // loop through the address removing more information
             // so we can get some geocode for a partial address
             // i.e. city -> state -> country
             $maxTries = 5;
             do {
                 if ($this->throttle) {
                     usleep(5000000);
                 }
                 $className = $config->geocodeMethod;
                 $className::format($params, TRUE);
                 // see if we got a geocode error, in this case we'll trigger a fatal
                 // CRM-13760
                 if (isset($params['geo_code_error']) && $params['geo_code_error'] == 'OVER_QUERY_LIMIT') {
                     CRM_Core_Error::fatal('Aborting batch geocoding. Hit the over query limit on geocoder.');
                 }
                 array_shift($params);
                 $maxTries--;
             } while ((!isset($params['geo_code_1']) || $params['geo_code_1'] == 'null') && $maxTries > 1);
             if (isset($params['geo_code_1']) && $params['geo_code_1'] != 'null') {
                 $totalGeocoded++;
                 $addressParams['geo_code_1'] = $params['geo_code_1'];
                 $addressParams['geo_code_2'] = $params['geo_code_2'];
                 $addressParams['postal_code'] = $params['postal_code'];
                 $addressParams['postal_code_suffix'] = CRM_Utils_Array::value('postal_code_suffix', $params);
             }
         }
         // parse street address
         if ($parseStreetAddress) {
             $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($dao->street_address);
             $success = TRUE;
             // consider address is automatically parseable,
             // when we should found street_number and street_name
             if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
                 $success = FALSE;
             }
             // do check for all elements.
             if ($success) {
                 $totalAddressParsed++;
             } elseif ($dao->street_address) {
                 //build contact edit url,
                 //so that user can manually fill the street address fields if the street address is not parsed, CRM-5886
                 $url = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$dao->id}");
                 $unparseableContactAddress[] = " Contact ID: " . $dao->id . " <a href =\"{$url}\"> " . $dao->street_address . " </a> ";
                 // reset element values.
                 $parsedFields = array_fill_keys(array_keys($parsedFields), '');
             }
             $addressParams = array_merge($addressParams, $parsedFields);
         }
         // finally update address object.
         if (!empty($addressParams)) {
             $address = new CRM_Core_DAO_Address();
             $address->id = $dao->address_id;
             $address->copyValues($addressParams);
             $address->save();
             $address->free();
         }
     }
     $this->returnMessages[] = ts("Addresses Evaluated: %1", array(1 => $totalAddresses)) . "\n";
     if ($processGeocode) {
         $this->returnMessages[] = ts("Addresses Geocoded: %1", array(1 => $totalGeocoded)) . "\n";
//.........这里部分代码省略.........
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:101,代码来源:BatchUpdate.php

示例5: processContacts

function processContacts(&$config, $start = null, $end = null)
{
    $contactClause = array();
    if ($start) {
        $contactClause[] = "c.id >= {$start}";
    }
    if ($end) {
        $contactClause[] = "c.id <= {$end}";
    }
    if (!empty($contactClause)) {
        $contactClause = ' AND ' . implode(' AND ', $contactClause);
    } else {
        $contactClause = null;
    }
    $query = "\nSELECT     c.id,\n           a.id as address_id,\n           a.street_address,\n           a.city,\n           a.postal_code,\n           s.name as state,\n           o.name as country\nFROM       civicrm_contact  c\nINNER JOIN civicrm_address        a ON a.contact_id = c.id\nINNER JOIN civicrm_country        o ON a.country_id = o.id\nLEFT  JOIN civicrm_state_province s ON a.state_province_id = s.id\nWHERE      c.id           = a.contact_id\n  AND      ( a.geo_code_1 is null OR a.geo_code_1 = 0 )\n  AND      ( a.geo_code_2 is null OR a.geo_code_2 = 0 )\n  AND      a.country_id is not null\n  {$contactClause}\nORDER BY a.id\n";
    $totalGeocoded = $totalAddresses = 0;
    $dao =& CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
    require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php';
    require_once 'CRM/Core/DAO/Address.php';
    while ($dao->fetch()) {
        $totalAddresses++;
        $params = array('street_address' => $dao->street_address, 'postal_code' => $dao->postal_code, 'city' => $dao->city, 'state_province' => $dao->state, 'country' => $dao->country);
        // loop through the address removing more information
        // so we can get some geocode for a partial address
        // i.e. city -> state -> country
        $maxTries = 5;
        do {
            if (defined('THROTTLE_REQUESTS') && THROTTLE_REQUESTS) {
                usleep(50000);
            }
            eval($config->geocodeMethod . '::format( $params, true );');
            array_shift($params);
            $maxTries--;
        } while (!isset($params['geo_code_1']) && $maxTries > 1);
        if (isset($params['geo_code_1'])) {
            $address = new CRM_Core_DAO_Address();
            $address->id = $dao->address_id;
            $address->geo_code_1 = $params['geo_code_1'];
            $address->geo_code_2 = $params['geo_code_2'];
            $address->save();
            $totalGeocoded++;
        }
    }
    echo ts("Addresses Evaluated: {$totalAddresses}\n");
    echo ts("Addresses Geocoded : {$totalGeocoded}\n");
    return;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:47,代码来源:UpdateAddress.php


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