本文整理匯總了PHP中api::get_now_time方法的典型用法代碼示例。如果您正苦於以下問題:PHP api::get_now_time方法的具體用法?PHP api::get_now_time怎麽用?PHP api::get_now_time使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類api
的用法示例。
在下文中一共展示了api::get_now_time方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _contact_to_group
/**
* 更新聯係人所在分組
* @param int $id
* @param string $type
*/
private function _contact_to_group($id, $type = 'add')
{
if ($this->get_method() != 'POST') {
$this->send_response(405, NULL, Kohana::lang('contact.method_not_exist'));
}
$id = (int) $id;
if ($type == 'add' and empty($id)) {
$this->send_response(400, NULL, Kohana::lang('contact.group_id_empty'));
}
if (!empty($id) and !$this->model->get_category_name($this->user_id, $id)) {
$this->send_response(400, NULL, Kohana::lang('contact.group_not_exist'));
}
$data = $this->get_data();
$ids = !empty($data['ids']) ? explode(',', $data['ids']) : array();
if (empty($ids)) {
$this->send_response(400, NULL, Kohana::lang('contact.contact_ids_empty'));
}
$result = array();
$update_ids = $this->model->move_contact_category($this->user_id, $id, $ids, $type);
if ($update_ids) {
$now = api::get_now_time();
foreach ($update_ids as $id) {
$result[] = array('id' => (int) $id, 'modified_at' => $now);
}
}
$this->send_response(200, $result, '', FALSE);
}
示例2: update_contact_modified
/**
* 更新聯係人修改時間
* @param int $user_id 用戶ID
* @param array $ids 聯係人ID
* @param string $source 來源
* @return bool
*/
public function update_contact_modified($user_id, $ids, $source)
{
$sql = sprintf("UPDATE %s SET modified = %d, SOURCE = %s WHERE uid = %d AND cid IN (%s)", $this->get_table($user_id, 'contacts'), api::get_now_time(), $this->db->escape($source), $user_id, implode(',', $ids));
$query = $this->db->query($sql);
if ($query) {
return TRUE;
}
return FALSE;
}
示例3: is_save_snapshot
/**
* 檢查是否需要保存快照
* @param int $user_id 用戶ID
* @param string $operation 操作說明
* @param bool $auto 是否自動保存快照
* @param bool $save 是否保存 ($auto == FALSE時生效)
* @return bool
*/
public function is_save_snapshot($user_id, $operation, $auto = TRUE, $save = FALSE)
{
//聯係人為空
$result = FALSE;
$history = $this->contact_mapper->get_last_history($user_id);
if ($auto == TRUE) {
if ($operation == 'recover_snapshot') {
$result = TRUE;
} else {
//粒度不分太細
switch (TRUE) {
//操作曆史為空
case $history === FALSE:
//上次操作應用不同
//上次操作應用不同
case $history['appid'] != $this->appid:
//上次操作設備不同
//上次操作設備不同
case $history['device_id'] != $this->device_id:
//上次操作說明不同
//上次操作說明不同
case $history['operation'] != $operation:
//上次操作與本次操作時間超過10分鍾
//上次操作與本次操作時間超過10分鍾
case api::get_now_time() - $history['dateline'] > 600:
$result = TRUE;
break;
//操作為合並操作
//操作為合並操作
case $operation === 'merge':
$deleted_ids = unserialize($history['deleted_ids']);
if (!empty($deleted_ids)) {
$result = TRUE;
}
break;
default:
$result = FALSE;
break;
}
}
$this->is_snapshot = api::get_now_time() == $history['dateline'] ? FALSE : $result;
$this->is_history = $result;
} else {
//根據設定參數備份快照
if ($save == TRUE) {
$this->is_snapshot = TRUE;
$this->is_history = TRUE;
} else {
$this->is_snapshot = FALSE;
$this->is_history = FALSE;
}
}
$this->history = $history;
$this->operation = $operation;
if ($this->is_snapshot) {
$this->count = $this->contact_mapper->get_count($user_id);
$this->category_count = $this->contact_mapper->get_category_count($user_id);
}
if ($operation == 'add') {
$this->count = isset($this->count) ? $this->count : $this->contact_mapper->get_count($user_id);
if ($this->count == 0) {
$this->is_snapshot = FALSE;
} else {
$this->category_count = $this->contact_mapper->get_category_count($user_id);
}
}
}