本文整理汇总了PHP中execute_delayed_write_query函数的典型用法代码示例。如果您正苦于以下问题:PHP execute_delayed_write_query函数的具体用法?PHP execute_delayed_write_query怎么用?PHP execute_delayed_write_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute_delayed_write_query函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elgg_geocode_location
/**
* Encode a location into a latitude and longitude, caching the result.
*
* Works by triggering the 'geocode' 'location' plugin
* hook, and requires a geocoding plugin to be installed.
*
* @param string $location The location, e.g. "London", or "24 Foobar Street, Gotham City"
* @return string|false
*/
function elgg_geocode_location($location)
{
global $CONFIG;
if (is_array($location)) {
return false;
}
$location = sanitise_string($location);
// Look for cached version
$query = "SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='{$location}'";
$cached_location = get_data_row($query);
if ($cached_location) {
return array('lat' => $cached_location->lat, 'long' => $cached_location->long);
}
// Trigger geocode event if not cached
$return = false;
$return = elgg_trigger_plugin_hook('geocode', 'location', array('location' => $location), $return);
// If returned, cache and return value
if ($return && is_array($return)) {
$lat = (double) $return['lat'];
$long = (double) $return['long'];
// Put into cache at the end of the page since we don't really care that much
$query = "INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache " . " (location, lat, `long`) VALUES ('{$location}', '{$lat}', '{$long}')" . " ON DUPLICATE KEY UPDATE lat='{$lat}', `long`='{$long}'";
execute_delayed_write_query($query);
}
return $return;
}
示例2: elgg_geocode_location
/**
* Encode a location into a latitude and longitude, caching the result.
*
* Works by triggering the 'geocode' 'location' plugin hook, and requires a geocoding module to be installed
* activated in order to work.
*
* @param String $location The location, e.g. "London", or "24 Foobar Street, Gotham City"
*/
function elgg_geocode_location($location)
{
global $CONFIG;
// Handle cases where we are passed an array (shouldn't be but can happen if location is a tag field)
if (is_array($location)) {
$location = implode(', ', $location);
}
$location = sanitise_string($location);
// Look for cached version
$cached_location = get_data_row("SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='{$location}'");
if ($cached_location) {
return array('lat' => $cached_location->lat, 'long' => $cached_location->long);
}
// Trigger geocode event if not cached
$return = false;
$return = trigger_plugin_hook('geocode', 'location', array('location' => $location), $return);
// If returned, cache and return value
if ($return && is_array($return)) {
$lat = (double) $return['lat'];
$long = (double) $return['long'];
// Put into cache at the end of the page since we don't really care that much
execute_delayed_write_query("INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache (location, lat, `long`) VALUES ('{$location}', '{$lat}', '{$long}') ON DUPLICATE KEY UPDATE lat='{$lat}', `long`='{$long}'");
}
return $return;
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:33,代码来源:location.php
示例3: elgg_geocode_location
/**
* Encode a location into a latitude and longitude, caching the result.
*
* Works by triggering the 'geocode' 'location' plugin hook, and requires a geocoding module to be installed
* activated in order to work.
*
* @param String $location The location, e.g. "London", or "24 Foobar Street, Gotham City"
*/
function elgg_geocode_location($location)
{
global $CONFIG;
$location = sanitise_string($location);
// Look for cached version
$cached_location = get_data_row("SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='{$location}'");
// Trigger geocode event
$return = false;
$return = trigger_plugin_hook('geocode', 'location', array('location' => $location, $return));
// If returned, cache and return value
if ($return && is_array($return)) {
$lat = (int) $return['lat'];
$long = (int) $return['long'];
// Put into cache at the end of the page since we don't really care that much
execute_delayed_write_query("INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache (lat, long) VALUES ({$lat}, {$long}) ON DUPLICATE KEY UPDATE lat={$lat} long={$long}");
}
return $return;
}
示例4: set_last_login
/**
* Sets the last logon time of the given user to right now.
*
* @param int $user_guid The user GUID
*/
function set_last_login($user_guid)
{
$user_guid = (int) $user_guid;
global $CONFIG;
$time = time();
execute_delayed_write_query("UPDATE {$CONFIG->dbprefix}users_entity set prev_last_login = last_login, last_login = {$time} where guid = {$user_guid}");
}
示例5: setLastLogin
/**
* Sets the last logon time of the given user to right now.
*
* @param int $user_guid The user GUID
*
* @return void
*/
function setLastLogin($user_guid)
{
$user_guid = (int) $user_guid;
$time = time();
$query = "UPDATE {$this->CONFIG->dbprefix}users_entity\n\t\t\tset prev_last_login = last_login, last_login = {$time} where guid = {$user_guid}";
execute_delayed_write_query($query);
}
示例6: setLastLogin
/**
* Sets the last logon time of the given user to right now.
*
* @param ElggUser $user User entity
* @return void
*/
public function setLastLogin(ElggUser $user)
{
$time = $this->getCurrentTime()->getTimestamp();
if ($user->last_login == $time) {
// no change required
return;
}
$query = "\n\t\t\tUPDATE {$this->table}\n\t\t\tSET\n\t\t\t\tprev_last_login = last_login,\n\t\t\t\tlast_login = :last_login\n\t\t\tWHERE guid = :guid\n\t\t";
$params = [':last_login' => $time, ':guid' => (int) $user->guid];
$user->prev_last_login = $user->last_login;
$user->last_login = $time;
execute_delayed_write_query($query, null, $params);
$this->entity_cache->set($user);
// If we save the user to memcache during this request, then we'll end up with the
// old (incorrect) attributes cached. Hence we want to invalidate as late as possible.
// the user object gets saved
register_shutdown_function(function () use($user) {
$user->storeInPersistedCache(_elgg_get_memcache('new_entity_cache'));
});
}
示例7: system_log
/**
* Log a system event related to a specific object.
*
* This is called by the event system and should not be called directly.
*
* @param object $object The object you're talking about.
* @param string $event The event being logged
* @return void
*/
function system_log($object, $event)
{
global $CONFIG;
static $log_cache;
static $cache_size = 0;
if ($object instanceof Loggable) {
/* @var \ElggEntity|\ElggExtender $object */
if (elgg_get_config('version') < 2012012000) {
// this is a site that doesn't have the ip_address column yet
return;
}
// reset cache if it has grown too large
if (!is_array($log_cache) || $cache_size > 500) {
$log_cache = array();
$cache_size = 0;
}
// Has loggable interface, extract the necessary information and store
$object_id = (int) $object->getSystemLogID();
$object_class = get_class($object);
$object_type = $object->getType();
$object_subtype = $object->getSubtype();
$event = sanitise_string($event);
$time = time();
$ip_address = sanitize_string(_elgg_services()->request->getClientIp());
if (!$ip_address) {
$ip_address = '0.0.0.0';
}
$performed_by = elgg_get_logged_in_user_guid();
if (isset($object->access_id)) {
$access_id = $object->access_id;
} else {
$access_id = ACCESS_PUBLIC;
}
if (isset($object->enabled)) {
$enabled = $object->enabled;
} else {
$enabled = 'yes';
}
if (isset($object->owner_guid)) {
$owner_guid = $object->owner_guid;
} else {
$owner_guid = 0;
}
// Create log if we haven't already created it
if (!isset($log_cache[$time][$object_id][$event])) {
$query = "INSERT into {$CONFIG->dbprefix}system_log\n\t\t\t\t(object_id, object_class, object_type, object_subtype, event,\n\t\t\t\tperformed_by_guid, owner_guid, access_id, enabled, time_created, ip_address)\n\t\t\tVALUES\n\t\t\t\t('{$object_id}','{$object_class}','{$object_type}', '{$object_subtype}', '{$event}',\n\t\t\t\t{$performed_by}, {$owner_guid}, {$access_id}, '{$enabled}', '{$time}', '{$ip_address}')";
execute_delayed_write_query($query);
$log_cache[$time][$object_id][$event] = true;
$cache_size += 1;
}
}
}