本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}