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


PHP DBManager::getAffectedRowCount方法代码示例

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


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

示例1: nextJob

 /**
  * Fetch the next job in the queue and mark it running
  * @param string $clientID ID of the client requesting the job
  * @return SugarJob
  */
 public function nextJob($clientID)
 {
     $now = $this->db->now();
     $queued = SchedulersJob::JOB_STATUS_QUEUED;
     $try = $this->jobTries;
     while ($try--) {
         // TODO: tranaction start?
         $id = $this->db->getOne("SELECT id FROM {$this->job_queue_table} WHERE execute_time <= {$now} AND status = '{$queued}' ORDER BY date_entered ASC");
         if (empty($id)) {
             return null;
         }
         $job = new SchedulersJob();
         $job->retrieve($id);
         if (empty($job->id)) {
             return null;
         }
         $job->status = SchedulersJob::JOB_STATUS_RUNNING;
         $job->client = $clientID;
         $client = $this->db->quote($clientID);
         // using direct query here to be able to fetch affected count
         // if count is 0 this means somebody changed the job status and we have to try again
         $res = $this->db->query("UPDATE {$this->job_queue_table} SET status='{$job->status}', date_modified={$now}, client='{$client}' WHERE id='{$job->id}' AND status='{$queued}'");
         if ($this->db->getAffectedRowCount($res) == 0) {
             // somebody stole our job, try again
             continue;
         } else {
             // to update dates & possible hooks
             $job->save();
             break;
         }
         // TODO: commit/check?
     }
     return $job;
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:39,代码来源:SugarJobQueue.php

示例2: testGetAffectedRowCount

 public function testGetAffectedRowCount()
 {
     if (!$this->_db->supports("affected_rows")) {
         $this->markTestSkipped('Skipping, backend doesn\'t support affected rows');
     }
     $beanIds = $this->_createRecords(1);
     $result = $this->_db->query("DELETE From contacts where id = '{$beanIds[0]}'");
     $this->assertEquals(1, $this->_db->getAffectedRowCount($result));
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:9,代码来源:DBManagerTest.php


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