当前位置: 首页>>代码示例>>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;未经允许,请勿转载。