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