我有一个看门狗表,并创建了一个不同的表,其中有来自看门狗的唯一变量,其 wids 作为键。我想要的是连接两个表(不同的表和看门狗表),以便将所有值与唯一变量连接起来。我这样做了:
$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();
}
我找不到我的错在哪里
最佳答案
您的字段别名u
不存在。您声明了 di
和 wa
,但没有声明 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();
关于php - 在 Drupal 上连接数据库表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29027812/