當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。