【问题标题】:insert values to a table from watchdog从看门狗向表中插入值
【发布时间】:2023-03-04 18:52:01
【问题描述】:

我有一个自定义模块,安装后它会创建一个表,其中包含 blablabla 名称和 uid、时间戳作为字段。现在我真正想要的是当 cron 运行以从看门狗表中获取值(uid,时间戳)并将其传递给我的 blablabla 表时。有没有办法做这件事?这是我的代码:

**
 * Implements hook_cron().
 */
function example_cron() {
      // Begin building the query.
      $query = db_select('watchdog', 'th')
        ->extend('PagerDefault')
        ->orderBy('wid')
        ->fields('th', array('uid', 'timestamp'))
        ->limit(2000);

      // Fetch the result set.
      $result = $query -> execute();
}

【问题讨论】:

    标签: php mysql database drupal drupal-7


    【解决方案1】:

    我做到了:

    f($r->rowCount() == 0) {
        $query = db_insert('blablabla')
          ->fields(array(
            'timestamp' => $timestamp,
            'wid' => $wid,
            'variables' => $variables,
         ))
         ->execute();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多