gpt4 book ai didi

php - 使用 PHP 获取 Drupal 7 中的用户列表

转载 作者:可可西里 更新时间:2023-10-31 23:53:26 24 4
gpt4 key购买 nike

如何使用 PHP 从 Drupal 7 数据库中获取用户名?

看这个: Is it possible to use the Drupal api to get a list of users?

这是针对 Drupal 6 的,我已经试过了,但它说

Call to undefined function db_fetch_object()

这是我的代码:

$result = db_query("SELECT name AS users_name FROM {users}");
while($row = db_fetch_object($result)) {
print_r($row);
}

最佳答案

试一试

$query = db_select('users', 'u');
   $query->fields('u', array('name'));
   $result = $query->execute();
   while($record = $result->fetchAssoc()) {
        print_r($record['name']);
   }

关于php - 使用 PHP 获取 Drupal 7 中的用户列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8455671/

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