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


PHP Scalr_Util_DateTime::getDateTimeDiff方法代碼示例

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


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

示例1: xListTasksAction

 /**
  * @param  int  $id
  */
 public function xListTasksAction($id = 0)
 {
     $sql = "\n            SELECT bt.*, (SELECT EXISTS (SELECT 1 FROM servers WHERE server_id = bt.server_id)) as server_exists\n            FROM bundle_tasks AS bt\n            LEFT JOIN farms AS f ON f.id = bt.farm_id\n            WHERE bt.env_id = ?\n            AND :FILTER:\n            AND (bt.farm_id IS NULL OR bt.farm_id IS NOT NULL AND {$this->request->getFarmSqlQuery()})\n        ";
     $args = [$this->getEnvironmentId()];
     if ($id) {
         $sql .= " AND bt.id = ?";
         $args[] = $id;
     }
     $response = $this->buildResponseFromSql2($sql, ['id', 'server_id', 'rolename', 'status', 'os_family', 'dtadded', 'dtstarted', 'created_by_email'], ['bt.id', 'rolename'], $args);
     foreach ($response["data"] as &$row) {
         $row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
         if (!$row['bundle_type']) {
             $row['bundle_type'] = "*";
         }
         if ($row['dtfinished'] && $row['dtstarted']) {
             $row['duration'] = Scalr_Util_DateTime::getDateTimeDiff($row['dtfinished'], $row['dtstarted']);
         }
         if ($row['dtfinished']) {
             $row['dtfinished'] = Scalr_Util_DateTime::convertTz($row['dtfinished']);
         }
         if ($row['dtstarted']) {
             $row['dtstarted'] = Scalr_Util_DateTime::convertTz($row['dtstarted']);
         }
     }
     $this->response->data($response);
 }
開發者ID:scalr,項目名稱:scalr,代碼行數:29,代碼來源:Bundletasks.php

示例2: xListTasksAction

 public function xListTasksAction()
 {
     $this->request->defineParams(array('bundleTaskId' => array('type' => 'int'), 'sort' => array('type' => 'string', 'default' => 'id'), 'dir' => array('type' => 'string', 'default' => 'DESC')));
     $sql = "SELECT * FROM bundle_tasks WHERE env_id = '" . $this->getEnvironmentId() . "'";
     if ($this->getParam('id') > 0) {
         $sql .= " AND id = " . $this->db->qstr($this->getParam('bundleTaskId'));
     }
     $response = $this->buildResponseFromSql($sql, array("server_id", "rolename", "failure_reason", "snapshot_id", "id"));
     foreach ($response["data"] as &$row) {
         $row['server_exists'] = DBServer::IsExists($row['server_id']);
         $row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
         if (!$row['bundle_type']) {
             $row['bundle_type'] = "*";
         }
         if ($row['dtfinished'] && $row['dtstarted']) {
             $row['duration'] = Scalr_Util_DateTime::getDateTimeDiff($row['dtfinished'], $row['dtstarted']);
         }
         if ($row['dtfinished']) {
             $row['dtfinished'] = Scalr_Util_DateTime::convertTz($row['dtfinished']);
         }
         if ($row['dtstarted']) {
             $row['dtstarted'] = Scalr_Util_DateTime::convertTz($row['dtstarted']);
         }
     }
     $this->response->data($response);
 }
開發者ID:recipe,項目名稱:scalr,代碼行數:26,代碼來源:Bundletasks.php

示例3: xListTasksAction

 public function xListTasksAction()
 {
     $this->request->defineParams(array('bundleTaskId' => array('type' => 'int'), 'sort' => array('type' => 'json', 'default' => array('property' => 'id', 'direction' => 'DESC'))));
     $sql = "SELECT * FROM bundle_tasks WHERE env_id = ?";
     $args = array($this->getEnvironmentId());
     if ($this->getParam('id') > 0) {
         $sql .= " AND id = ?";
         $args[] = $this->getParam('bundleTaskId');
     }
     $response = $this->buildResponseFromSql2($sql, array('id', 'server_id', 'rolename', 'status', 'os_family', 'dtadded', 'dtstarted', 'created_by_email'), array(), $args);
     foreach ($response["data"] as &$row) {
         $row['server_exists'] = DBServer::IsExists($row['server_id']);
         $row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
         if (!$row['bundle_type']) {
             $row['bundle_type'] = "*";
         }
         if ($row['dtfinished'] && $row['dtstarted']) {
             $row['duration'] = Scalr_Util_DateTime::getDateTimeDiff($row['dtfinished'], $row['dtstarted']);
         }
         if ($row['dtfinished']) {
             $row['dtfinished'] = Scalr_Util_DateTime::convertTz($row['dtfinished']);
         }
         if ($row['dtstarted']) {
             $row['dtstarted'] = Scalr_Util_DateTime::convertTz($row['dtstarted']);
         }
     }
     $this->response->data($response);
 }
開發者ID:rickb838,項目名稱:scalr,代碼行數:28,代碼來源:Bundletasks.php

示例4: xListTasksAction

 /**
  * @param  int  $id
  */
 public function xListTasksAction($id = 0)
 {
     $sql = "\n            SELECT bt.*, (SELECT EXISTS (SELECT 1 FROM servers WHERE server_id = bt.server_id)) as server_exists\n            FROM bundle_tasks AS bt\n            LEFT JOIN farms AS f ON f.id = bt.farm_id\n            WHERE bt.env_id = ? AND :FILTER:\n        ";
     $args = [$this->getEnvironmentId()];
     if ($id) {
         $sql .= " AND bt.id = ?";
         $args[] = $id;
     }
     if (!$this->request->isAllowed(Acl::RESOURCE_FARMS)) {
         $q = ["f.id IS NULL"];
         if ($this->request->isAllowed(Acl::RESOURCE_TEAM_FARMS)) {
             $t = array_map(function ($t) {
                 return $t['id'];
             }, $this->user->getTeams());
             if (count($t)) {
                 $q[] = "f.team_id IN(" . join(',', $t) . ")";
             }
         }
         if ($this->request->isAllowed(Acl::RESOURCE_OWN_FARMS)) {
             $q[] = "f.created_by_id = ?";
             $args[] = $this->user->getId();
         }
         $sql .= ' AND (' . join(' OR ', $q) . ')';
     }
     $response = $this->buildResponseFromSql2($sql, ['id', 'server_id', 'rolename', 'status', 'os_family', 'dtadded', 'dtstarted', 'created_by_email'], ['bt.id', 'rolename'], $args);
     foreach ($response["data"] as &$row) {
         $row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
         if (!$row['bundle_type']) {
             $row['bundle_type'] = "*";
         }
         if ($row['dtfinished'] && $row['dtstarted']) {
             $row['duration'] = Scalr_Util_DateTime::getDateTimeDiff($row['dtfinished'], $row['dtstarted']);
         }
         if ($row['dtfinished']) {
             $row['dtfinished'] = Scalr_Util_DateTime::convertTz($row['dtfinished']);
         }
         if ($row['dtstarted']) {
             $row['dtstarted'] = Scalr_Util_DateTime::convertTz($row['dtstarted']);
         }
     }
     $this->response->data($response);
 }
開發者ID:mheydt,項目名稱:scalr,代碼行數:45,代碼來源:Bundletasks.php


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