【问题标题】:Join DB tables on Drupal在 Drupal 上加入数据库表
【发布时间】:2015-03-13 08:32:23
【问题描述】:

我有一个看门狗表,我创建了一个不同的表,我有看门狗的唯一变量,它们的 wids 作为键。我想要的是加入 2 个表(不同的表和看门狗),以便将所有值与唯一变量连接起来。我这样做了:

$query = db_select('distinct', 'di');
    $query -> join('watchdog', 'wa', 'di.wid = wa.wid');
    $query -> fields('u', array('variables', 'type', 'severity','message', 'wid', 'timestamp'));
    $result = $query->execute();
  }

我找不到我的错在哪里

【问题讨论】:

    标签: php mysql database drupal drupal-7


    【解决方案1】:

    您的字段别名 u 不存在。您声明了diwa,但没有声明u。把这个改成wa,我想选中的列来自watchdog表。

    $query = db_select('distinct', 'di');
    $query->join('watchdog', 'wa', 'di.wid = wa.wid');
    $query->fields('wa', array('variables', 'type', 'severity','message', 'wid', 'timestamp'));
    
    $result = $query->execute();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-18
      • 1970-01-01
      相关资源
      最近更新 更多