本文整理汇总了PHP中rcube_db::fromunixtime方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_db::fromunixtime方法的具体用法?PHP rcube_db::fromunixtime怎么用?PHP rcube_db::fromunixtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcube_db
的用法示例。
在下文中一共展示了rcube_db::fromunixtime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: expunge
/**
* Delete cache entries older than TTL
*
* @param string $ttl Lifetime of message cache entries
*/
function expunge($ttl)
{
// get expiration timestamp
$ts = get_offset_time($ttl, -1);
$this->db->query("DELETE FROM " . $this->db->table_name('cache_messages') . " WHERE changed < " . $this->db->fromunixtime($ts));
$this->db->query("DELETE FROM " . $this->db->table_name('cache_index') . " WHERE changed < " . $this->db->fromunixtime($ts));
$this->db->query("DELETE FROM " . $this->db->table_name('cache_thread') . " WHERE changed < " . $this->db->fromunixtime($ts));
}
示例2: DateTime
/**
* Update user's failed_login timestamp and counter
*/
function failed_login()
{
if ($this->ID && ($rate = (int) $this->rc->config->get('login_rate_limit', 3))) {
if (empty($this->data['failed_login'])) {
$failed_login = new DateTime('now');
$counter = 1;
} else {
$failed_login = new DateTime($this->data['failed_login']);
$threshold = new DateTime('- 60 seconds');
if ($failed_login < $threshold) {
$failed_login = new DateTime('now');
$counter = 1;
}
}
$this->db->query("UPDATE " . $this->db->table_name('users', true) . " SET `failed_login` = " . $this->db->fromunixtime($failed_login->format('U')) . ", `failed_login_counter` = " . ($counter ?: "`failed_login_counter` + 1") . " WHERE `user_id` = ?", $this->ID);
}
}