我无法在 table 中创建值
I cannot create values in my table
我有这段代码,它在 cron 运行时获取看门狗 table 的值,我想获取 wid 和时间戳并将其传递到我的 table 中,名称为 blablabla:
function blablabla_cron() {
// Begin building the query.
$query = db_select('watchdog', 'th')
->extend('PagerDefault')
->orderBy('wid')
->fields('th', array('variables', 'type', 'severity', 'message', 'wid', 'timestamp'))
->limit(2000);
// Fetch the result set.
$result = $query -> execute();
// Loop through each item and add to $row.
$already_processed = array();
foreach ($result as $row) {
$unique_value = unserialize($row -> variables);
if (in_array($unique_value, $already_processed))
continue;
$already_processed[] = $unique_value;
blablabla_table($row);
}
}
function blablabla_table($row) {
$timestamp = $row -> timestamp;
$wid = $row -> wid;
$num_updated = db_update('blablabla')
->fields(array(
'wid' => $wid,
'timestamp' => $timestamp,
))
->condition('created', REQUEST_TIME - 3600, '>=')
->execute();
}
我不明白代码中哪里是我的错,因为 table 仍然是空的 :( :(
我在 blablabla_table 函数中解决了我的问题,我得到:
function blablabla_table($row) {
$timestamp = $row -> timestamp;
$wid = $row -> wid;
$nid = db_insert('error_log_jira')
->fields(array(
'timestamp' => $timestamp,
'wid' => $wid,
))
->execute();
}
我有这段代码,它在 cron 运行时获取看门狗 table 的值,我想获取 wid 和时间戳并将其传递到我的 table 中,名称为 blablabla:
function blablabla_cron() {
// Begin building the query.
$query = db_select('watchdog', 'th')
->extend('PagerDefault')
->orderBy('wid')
->fields('th', array('variables', 'type', 'severity', 'message', 'wid', 'timestamp'))
->limit(2000);
// Fetch the result set.
$result = $query -> execute();
// Loop through each item and add to $row.
$already_processed = array();
foreach ($result as $row) {
$unique_value = unserialize($row -> variables);
if (in_array($unique_value, $already_processed))
continue;
$already_processed[] = $unique_value;
blablabla_table($row);
}
}
function blablabla_table($row) {
$timestamp = $row -> timestamp;
$wid = $row -> wid;
$num_updated = db_update('blablabla')
->fields(array(
'wid' => $wid,
'timestamp' => $timestamp,
))
->condition('created', REQUEST_TIME - 3600, '>=')
->execute();
}
我不明白代码中哪里是我的错,因为 table 仍然是空的 :( :(
我在 blablabla_table 函数中解决了我的问题,我得到:
function blablabla_table($row) {
$timestamp = $row -> timestamp;
$wid = $row -> wid;
$nid = db_insert('error_log_jira')
->fields(array(
'timestamp' => $timestamp,
'wid' => $wid,
))
->execute();
}