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


PHP AIR2_Record::discriminate方法代码示例

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


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

示例1: discriminate

 /**
  * Set the correct sv_type based on which fields are populated.
  *
  * @param array   $data
  * @param TankSource $tsrc
  * @param int     $op
  */
 public function discriminate($data, &$tsrc, $op = null)
 {
     if (isset($data['sv_value']) || isset($data['sv_basis'])) {
         $this->sv_type = SrcVita::$TYPE_EXPERIENCE;
     } elseif (isset($data['sv_notes'])) {
         $this->sv_type = SrcVita::$TYPE_INTEREST;
     }
     parent::discriminate($data, $tsrc, $op);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:16,代码来源:SrcVita.php

示例2: discriminate

 /**
  * By default, discriminate throws conflicts on existing, non-matching
  * values.  Here, we'll allow overwriting the src_status.
  *
  * @param array   $data
  * @param TankSource $tsrc
  * @param int     $op
  */
 public function discriminate($data, &$tsrc, $op = null)
 {
     if (isset($data['src_status']) && strlen($data['src_status']) == 1) {
         $this->src_status = $data['src_status'];
     }
     parent::discriminate($data, $tsrc, $op);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:15,代码来源:Source.php

示例3: discriminate

 /**
  * Alias will overwrite existing values without conflict.  For now, only
  * allow a source to have one SrcAlias record.
  *
  * @param array   $data
  * @param TankSource $tsrc
  * @param int     $op
  */
 public function discriminate($data, &$tsrc, $op = null)
 {
     // search for existing
     $q = $this->getTable()->createQuery();
     $q->where('sa_src_id = ?', $this->sa_src_id);
     $existing_rec = $q->fetchOne(array(), Doctrine::HYDRATE_ARRAY);
     if ($existing_rec) {
         $this->assignIdentifier($existing_rec['sa_id']);
         $this->hydrate($existing_rec);
     }
     // call parent
     parent::discriminate($data, $tsrc, $op);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:21,代码来源:SrcAlias.php

示例4: discriminate

 /**
  * Make sure the source doesn't get duplicate addresses
  *
  * @param array   $data
  * @param TankSource $tsrc
  * @param unknown $op   (optional)
  */
 public function discriminate($data, &$tsrc, $op = null)
 {
     // search for existing
     if ($op != AIR2_DISCRIM_ADD) {
         $q = $this->getTable()->createQuery();
         $q->where('smadd_src_id = ?', $this->smadd_src_id);
         // ID existing by line_1, city, or zip
         $subqry = array();
         $params = array();
         if (isset($data['smadd_line_1'])) {
             $subqry[] = 'smadd_line_1 = ?';
             $params[] = $data['smadd_line_1'];
         }
         if (isset($data['smadd_city'])) {
             $subqry[] = 'smadd_city = ?';
             $params[] = $data['smadd_city'];
         }
         if (isset($data['smadd_zip'])) {
             $subqry[] = 'smadd_zip = ?';
             $params[] = $data['smadd_zip'];
         }
         $subqry = implode(' OR ', $subqry);
         if ($subqry) {
             $q->andWhere("({$subqry})", $params);
             $existing_rec = $q->fetchOne(array(), Doctrine::HYDRATE_ARRAY);
             if ($existing_rec) {
                 $this->assignIdentifier($existing_rec['smadd_id']);
                 $this->hydrate($existing_rec);
             }
         }
         $q->free();
         //cleanup
     }
     // just set primary --- actual logic in postsave hook
     if (isset($data['smadd_primary_flag'])) {
         $this->smadd_primary_flag = $data['smadd_primary_flag'];
         unset($data['smadd_primary_flag']);
     }
     // set remaining data with parent
     parent::discriminate($data, $tsrc, $op);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:48,代码来源:SrcMailAddress.php

示例5: discriminate

 /**
  * Check for existing facts
  *
  * @param array   $data
  * @param TankSource $tsrc
  * @param unknown $op   (optional)
  */
 public function discriminate($data, &$tsrc, $op = null)
 {
     $overwrite_facts = array('household_income', 'education_level', 'political_affiliation', 'religion', 'source_website', 'lifecycle', 'timezone');
     $overwrite = false;
     // determine if this SrcFact exists yet
     $id = array('sf_src_id' => $this->sf_src_id, 'sf_fact_id' => $this->sf_fact_id);
     $q = Doctrine_Query::create()->from('SrcFact sf');
     $q->leftJoin('sf.Fact f');
     $q->where('sf_fact_id = ?', $this->sf_fact_id);
     $q->andWhere('sf_src_id = ?', $this->sf_src_id);
     $q->select('sf.*, f.fact_identifier as fident');
     $existing_rec = $q->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);
     $q->free();
     if ($existing_rec) {
         $this->_disc_fact_ident = $existing_rec['fident'];
         unset($existing_rec['fident']);
         $this->assignIdentifier($id);
         $this->hydrate($existing_rec);
     }
     // update the record
     parent::discriminate($data, $tsrc, $op);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:29,代码来源:SrcFact.php

示例6: discriminate

 /**
  * Make sure the source doesn't get duplicate sem_emails
  *
  * @param array   $data
  * @param TankSource $tsrc
  * @param unknown $op   (optional)
  */
 public function discriminate($data, &$tsrc, $op = null)
 {
     // ignore if sem_email isn't set
     if (isset($data['sem_email'])) {
         // search for existing
         if ($op != AIR2_DISCRIM_ADD) {
             $q = $this->getTable()->createQuery();
             $q->where('sem_src_id = ?', $this->sem_src_id);
             $q->andWhere('sem_email = ?', $data['sem_email']);
             $existing_rec = $q->fetchOne(array(), Doctrine::HYDRATE_ARRAY);
             if ($existing_rec) {
                 $this->assignIdentifier($existing_rec['sem_id']);
                 $this->hydrate($existing_rec);
             }
             $q->free();
             //cleanup
         }
         // just set primary --- actual logic in postsave hook
         if (isset($data['sem_primary_flag'])) {
             $this->sem_primary_flag = $data['sem_primary_flag'];
             unset($data['sem_primary_flag']);
         }
         // email addresses should ALWAYS be lowercased
         $data['sem_email'] = strtolower($data['sem_email']);
         if ($this->sem_email) {
             $this->sem_email = strtolower($this->sem_email);
         }
         // set remaining data with parent
         parent::discriminate($data, $tsrc, $op);
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:38,代码来源:SrcEmail.php

示例7: resolve_conflicts

 /**
  * Attempts to discriminate data being saved to a record, tracking any
  * conflicts.  Note that the AIR2_Record->discriminate() method should
  * save the record, so call it from a try-catch.
  *
  * @param AIR2_Record $rec
  * @param array   $data
  * @param TankSource $tsrc
  * @param int     $op
  */
 protected function resolve_conflicts($rec, $data, $tsrc, $op = null)
 {
     // ignore this piece of the tank_source
     if ($op == AIR2_DISCRIM_IGNORE) {
         return;
     }
     // unset any null data vals
     foreach ($data as $key => $val) {
         if (is_null($val)) {
             unset($data[$key]);
         } elseif (is_string($val) && strlen($val) == 0) {
             unset($data[$key]);
         }
     }
     // discriminate, if we have data
     if (count($data) > 0) {
         $rec->discriminate($data, $tsrc, $op);
         // try to save the record
         try {
             $rec->save();
         } catch (Doctrine_Validator_Exception $e) {
             $cls = get_class($rec);
             $stack = $rec->getErrorStack()->toArray();
             foreach ($stack as $col => $problem) {
                 $tsrc->add_conflict($cls, $col, $problem);
             }
         } catch (Exception $e) {
             $cls = get_class($rec);
             $msg = $e->getMessage();
             $tsrc->add_error("FATAL ERROR on {$cls} - {$msg}");
         }
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:43,代码来源:Discriminator.php


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