當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CModel::pdo_connection方法代碼示例

本文整理匯總了PHP中CModel::pdo_connection方法的典型用法代碼示例。如果您正苦於以下問題:PHP CModel::pdo_connection方法的具體用法?PHP CModel::pdo_connection怎麽用?PHP CModel::pdo_connection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CModel的用法示例。


在下文中一共展示了CModel::pdo_connection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: count_Jobs

 public static function count_Jobs($pdo_connection, $period_timestamps, $job_status = null, $job_level = null)
 {
     $statment = null;
     $where = null;
     $tablename = 'Job';
     $fields = array('COUNT(*) as job_count');
     $intervals = null;
     // Check PDO object
     if (!is_a($pdo_connection, 'PDO') and is_null($pdo_connection)) {
         throw new Exception('Unvalid PDO object provided in count_Jobs() function');
     }
     // PDO object singleton
     if (is_null(CModel::$pdo_connection)) {
         CModel::$pdo_connection = $pdo_connection;
     }
     // Getting timestamp interval
     $intervals = CDBQuery::get_Timestamp_Interval($period_timestamps);
     // Defining interval depending on job status
     if (!is_null($job_status)) {
         switch ($job_status) {
             case 'running':
                 $where = array('(starttime BETWEEN ' . $intervals['starttime'] . ' AND ' . $intervals['endtime'] . ') ');
                 break;
             case 'waiting':
                 // We don't use interval for waiting jobs
                 break;
             default:
                 $where = array('(endtime BETWEEN ' . $intervals['starttime'] . ' AND ' . $intervals['endtime'] . ') ');
                 break;
         }
     } else {
         $where[] = '(endtime BETWEEN ' . $intervals['starttime'] . ' AND ' . $intervals['endtime'] . ') ';
     }
     // Job status
     if (!is_null($job_status)) {
         switch ($job_status) {
             case 'running':
                 $where[] = "JobStatus = 'R'";
                 break;
             case 'completed':
                 $where[] = "JobStatus = 'T' ";
                 break;
             case 'failed':
                 $where[] = "JobStatus IN ('f','E') ";
                 break;
             case 'canceled':
                 $where[] = "JobStatus = 'A' ";
                 break;
             case 'waiting':
                 $where[] = "JobStatus IN ('F','S','M','m','s','j','c','d','t','p','C') ";
                 break;
         }
         // end switch
     }
     // Job level
     if (!is_null($job_level)) {
         $where[] = "Level = '{$job_level}' ";
     }
     // Building SQL statment
     $statment = array('table' => $tablename, 'fields' => $fields, 'where' => $where);
     $statment = CDBQuery::get_Select($statment);
     // Execute SQL statment
     $result = CDBUtils::runQuery($statment, $pdo_connection);
     $result = $result->fetch();
     return $result['job_count'];
 }
開發者ID:ExaMuff,項目名稱:bacula-web,代碼行數:66,代碼來源:jobs.model.php


注:本文中的CModel::pdo_connection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。