gpt4 book ai didi

php - 我无法在表中创建值

转载 作者:行者123 更新时间:2023-11-29 22:48:05 25 4
gpt4 key购买 nike

我有这段代码,它在 cron 运行时获取看门狗表的值,我想获取 wid 和时间戳并将其传递到名为 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();
}

我无法理解代码中的哪里是我的错,因为表格仍然是空的:( :(

最佳答案

我在 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();
}

关于php - 我无法在表中创建值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29008247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com