本文整理匯總了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);
}
}