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


PHP Contacts::insert方法代码示例

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


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

示例1: addAction

 /** Add new staff member
  */
 public function addAction()
 {
     $form = new ContactForm();
     $form->submit->setLabel('Add a new Scheme contact');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $address = $form->getValue('address_1') . ',' . $form->getValue('address_2') . ',' . $form->getValue('town') . ',' . $form->getValue('county') . ',' . $form->getValue('postcode') . ', UK';
             $coords = $this->_geocoder->getCoordinates($address);
             if ($coords) {
                 $lat = $coords['lat'];
                 $long = $coords['lon'];
                 $pm = new Pas_Service_Geoplanet();
                 $place = $pm->reverseGeoCode($lat, $lon);
                 $woeid = $place['woeid'];
             } else {
                 $lat = NULL;
                 $lon = NULL;
                 $woeid = NULL;
             }
             $insertData = array('firstname' => $form->getValue('firstname'), 'lastname' => $form->getValue('lastname'), 'role' => $form->getValue('role'), 'dbaseID' => $form->getValue('dbaseID'), 'email_one' => $form->getValue('email_one'), 'email_two' => $form->getValue('email_two'), 'address_1' => $form->getValue('address_1'), 'address_2' => $form->getValue('address_2'), 'region' => $form->getValue('region'), 'town' => $form->getValue('town'), 'county' => $form->getValue('county'), 'postcode' => $form->getValue('postcode'), 'country' => $form->getValue('country'), 'identifier' => $form->getValue('identifier'), 'telephone' => $form->getValue('telephone'), 'fax' => $form->getValue('fax'), 'website' => $form->getValue('website'), 'profile' => $form->getValue('profile'), 'alumni' => $form->getValue('alumni'), 'created' => $this->getTimeForForms(), 'createdBy' => $this->getIdentityForForms(), 'latitude' => $lat, 'longitude' => $lon, 'woeid' => $woeid);
             foreach ($insertData as $key => $value) {
                 if (is_null($value) || $value == "") {
                     unset($insertData[$key]);
                 }
             }
             $contacts = new Contacts();
             $insert = $contacts->insert($insertData);
             $this->_flashMessenger->addMessage('Scheme contact created!');
             $this->_redirect($this->_redirectUrl . 'contact/id/' . $insert);
         } else {
             $form->populate($formData);
         }
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:38,代码来源:ContactsController.php

示例2: map_related_to_contacts

 /**
  * function to map related to (contacts) for potentials while importing
  * checks if the contact exists else adds a new contact
  * @param string $contact_name
  * @return integer idcontacts
  */
 public function map_related_to_contacts($contact_name)
 {
     if (strlen($contact_name) > 2) {
         $contact_name = trim($contact_name);
         $do_contact = new Contacts();
         $qry = "\n\t\t\tselect `idcontacts`\n\t\t\tfrom  `contacts`\n\t\t\twhere `deleted` = 0 \n\t\t\tAND iduser = " . $_SESSION["do_user"]->iduser . "\n\t\t\tAND \n\t\t\t(\n\t\t\t\tconcat(firstname,' ',lastname) = ?\n\t\t\t\tor\n\t\t\t\tconcat(lastname,' ',firstname) = ?\n\t\t\t)\n\t\t\t";
         $do_contact->query($qry, array($contact_name, $contact_name));
         if ($do_contact->getNumRows() > 0) {
             $do_contact->next();
             return $do_contact->idcontacts;
         } else {
             $contact_name_explode = explode(" ", $contact_name);
             $do_contact->insert("contacts", array("firstname" => CommonUtils::purify_input($contact_name_explode[0]), "lastname" => CommonUtils::purify_input($contact_name_explode[1]), "iduser" => $_SESSION["do_user"]->iduser));
             $idcontacts = $do_contact->getInsertId();
             //adding the added_on
             $q_upd = "\n\t\t\t\tupdate `contacts` \n\t\t\t\tset `added_on` = '" . date("Y-m-d H:i:s") . "'\n\t\t\t\twhere `idcontacts` = " . $idcontacts;
             $do_contact->query($q_upd);
             $do_contact->insert("contacts_custom_fld", array("idcontacts" => $idcontacts));
             $do_contact->insert("contacts_address", array("idcontacts" => $idcontacts));
             $do_data_history = new DataHistory();
             $do_data_history->add_history($idcontacts, 4, 'add');
             $do_data_history->free();
             return $idcontacts;
         }
     }
 }
开发者ID:sQcrm,项目名称:sqcrm,代码行数:32,代码来源:PotentialsImport.class.php


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