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


PHP PartnerPeer::getPartnerPriorityFactorByPartner方法代码示例

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


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

示例1: updatePartnerLoad

 public static function updatePartnerLoad($partnerId, $jobType, $jobSubType = null, PropelPDO $con = null)
 {
     $partner = PartnerPeer::retrieveByPK($partnerId);
     $priorityFactor = PartnerPeer::getPartnerPriorityFactorByPartner($partner);
     $maxQuota = $partner->getJobTypeQuota($jobType, $jobSubType);
     if (!$maxQuota) {
         $maxQuota = BatchJobLockPeer::getMaxJobsForPartner($jobType);
     }
     $dcId = kDataCenterMgr::getCurrentDcId();
     // Hack to avoid the not-null constaint on job sub type
     if (is_null($jobSubType)) {
         $jobSubType = 0;
     }
     $c = new Criteria();
     $c->add(self::PARTNER_ID, $partnerId);
     $c->add(self::JOB_TYPE, $jobType);
     $c->add(self::JOB_SUB_TYPE, $jobSubType);
     $c->add(self::DC, $dcId);
     $oldPartnerLoad = self::doSelectOne($c);
     if ($oldPartnerLoad === null) {
         try {
             // Try to insert new entry
             $partnerLoad = new PartnerLoad();
             $partnerLoad->setPartnerId($partnerId);
             $partnerLoad->setJobType($jobType);
             $partnerLoad->setJobSubType($jobSubType);
             $partnerLoad->setPartnerLoad(1);
             $partnerLoad->setDc($dcId);
             $partnerLoad->setWeightedPartnerLoad($priorityFactor);
             $partnerLoad->setQuota($maxQuota - 1);
             $res = $partnerLoad->save();
             if ($res == 1) {
                 return;
                 // if we arrived here, it means the insert was successful
             }
         } catch (Exception $e) {
             // probably a unique constraint - use the updae version below
         }
     }
     $table = PartnerLoadPeer::TABLE_NAME;
     $colPartnerLoad = PartnerLoadPeer::PARTNER_LOAD;
     $colWeightedPartnerLoad = PartnerLoadPeer::WEIGHTED_PARTNER_LOAD;
     $colJobType = PartnerLoadPeer::JOB_TYPE;
     $colJobSubType = PartnerLoadPeer::JOB_SUB_TYPE;
     $colPartnerId = PartnerLoadPeer::PARTNER_ID;
     $colDC = PartnerLoadPeer::DC;
     $colQuota = PartnerLoadPeer::QUOTA;
     $sql = "UPDATE {$table} ";
     $sql .= "SET {$colPartnerLoad} = ({$colPartnerLoad} + 1)";
     $sql .= ", {$colWeightedPartnerLoad} = ({$colWeightedPartnerLoad} + {$priorityFactor})";
     $sql .= ", {$colQuota} = ({$colQuota} - 1)";
     $sql .= "WHERE {$colJobType} = {$jobType} ";
     $sql .= "AND {$colJobSubType} = {$jobSubType} ";
     $sql .= "AND {$colPartnerId} = {$partnerId} ";
     $sql .= "AND {$colDC} = {$dcId} ";
     try {
         $affectedRows = $con->exec($sql);
     } catch (Exception $e) {
         KalturaLog::err("Failed to update partner load with error : " . $e->getMessage());
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:61,代码来源:PartnerLoadPeer.php


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