function elysia_cron_set in Elysia Cron 6.2
Same name and namespace in other branches
- 5.2 elysia_cron.module \elysia_cron_set()
- 5 elysia_cron.module \elysia_cron_set()
- 6 elysia_cron.module \elysia_cron_set()
- 7.2 elysia_cron.module \elysia_cron_set()
- 7 elysia_cron.module \elysia_cron_set()
24 calls to elysia_cron_set()
- elysia_cron_execute_aborted in ./
elysia_cron.module - elysia_cron_internal_execute_channel in ./
elysia_cron.module - Internal function to execute all jobs in a channel elysia_cron_lock_env() must be called BEFORE calling this method
- elysia_cron_internal_execute_job in ./
elysia_cron.module - Internal function to execute a single job
- elysia_cron_reset_channel_disabled in ./
elysia_cron.module - elysia_cron_reset_channel_rule in ./
elysia_cron.module
File
- ./
elysia_cron.module, line 363
Code
function elysia_cron_set($name, $channel = false, $values = array()) {
if ($channel) {
$name = ':' . $name;
}
if (EC_DRUPAL_VERSION >= 7) {
db_merge('elysia_cron')
->key(array(
'name' => $name,
))
->fields($values)
->execute();
}
else {
$fields = array(
"name" => "'%s'",
"disable" => "%d",
"rule" => "'%s'",
"weight" => "%d",
"context" => "'%s'",
"running" => "%d",
"last_run" => "%d",
"last_aborted" => "%d",
"abort_count" => "%d",
"last_abort_function" => "'%s'",
"last_execution_time" => "%d",
"execution_count" => "%d",
"avg_execution_time" => "%f",
"max_execution_time" => "%d",
"last_shutdown_time" => "%d",
);
$ifields = array(
'disable',
'running',
'last_run',
'last_aborted',
'abort_count',
'last_execution_time',
'execution_count',
'avg_execution_time',
'max_execution_time',
'last_shutdown_time',
);
if (db_result(db_query("SELECT 1 FROM {elysia_cron} WHERE name = '%s'", $name))) {
$uquery = array();
$uvalues = array();
foreach ($values as $k => $v) {
if (is_null($v) && !in_array($k, $ifields)) {
$uquery[] = $k . ' = NULL';
}
else {
$uquery[] = $k . ' = ' . $fields[$k];
$uvalues[] = $v;
}
}
$uvalues[] = $name;
db_query("update {elysia_cron} set " . implode(', ', $uquery) . " where name = '%s'", $uvalues);
}
else {
foreach ($ifields as $f) {
if (empty($values[$f])) {
$values[$f] = 0;
}
}
$values['name'] = $name;
$iquery1 = array();
$iquery2 = array();
$ivalues = array();
foreach ($values as $k => $v) {
if (!is_null($v)) {
$iquery1[] = $k;
$iquery2[] = $fields[$k];
$ivalues[] = $v;
}
}
db_query("insert into {elysia_cron} (" . implode(', ', $iquery1) . ") values (" . implode(', ', $iquery2) . ")", $ivalues);
}
}
global $elysia_cron_db_cache;
unset($elysia_cron_db_cache[$name]);
}