本文整理汇总了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'];
}