Scalr\Model\Entity\Server::setTimeLog PHP Method

setTimeLog() public method

Add record for servers_launch_timelog
public setTimeLog ( string $field, integer $secondsSinceBoot = null, integer $secondsSinceStart = null ) : boolean
$field string Field name which we should update
$secondsSinceBoot integer optional Seconds since boot. Field is used for field ts_hi If field is ts_launched, ts_hi, ts_bhu, ts_hu, value could be used as timestamp
$secondsSinceStart integer optional Seconds since start. Field is used for field ts_hi
return boolean
    public function setTimeLog($field, $secondsSinceBoot = null, $secondsSinceStart = null)
    {
        if ($this->farmRoleId) {
            if ($field == 'ts_created') {
                $this->db()->Execute("\n                    INSERT INTO servers_launch_timelog\n                    SET `server_id` = ?,\n                        `os_family` = ?,\n                        `os_version` = ?,\n                        `cloud` = ?,\n                        `cloud_location` = ?,\n                        `server_type` = ?,\n                        `behaviors` = ?,\n                        `ts_created` = ?\n                    ON DUPLICATE KEY UPDATE\n                        `ts_created` = ?\n                ", [$this->serverId, $this->getFarmRole()->getRole()->getOs()->family, $this->getFarmRole()->getRole()->getOs()->version, $this->platform, $this->cloudLocation, $this->type, implode(",", $this->getFarmRole()->getRole()->getBehaviors()), time(), time()]);
            } else {
                if ($field == 'ts_hi') {
                    $this->db()->Execute("\n                    UPDATE servers_launch_timelog\n                    SET `time_to_boot` = ?,\n                        `time_to_hi` = ?,\n                        `last_init_status` = ?,\n                        `{$field}` = ?\n                    WHERE server_id=?\n                ", [$secondsSinceBoot - $secondsSinceStart, $secondsSinceStart, $this->status, time(), $this->serverId]);
                } else {
                    if (in_array($field, ['ts_launched', 'ts_hi', 'ts_bhu', 'ts_hu'])) {
                        $this->db()->Execute("\n                    UPDATE servers_launch_timelog\n                    SET `last_init_status` = ?,\n                        `{$field}` = ?\n                    WHERE server_id=?\n                ", [$this->status, $secondsSinceBoot ?: time(), $this->serverId]);
                    } else {
                        return false;
                    }
                }
            }
        } else {
            return false;
        }
        return true;
    }