【问题标题】:How to fetch only one record from DB and to not store it in array in DRUPAL如何从数据库中仅获取一条记录而不将其存储在 DRUPAL 的数组中
【发布时间】:2015-01-10 12:27:14
【问题描述】:
 $id = db_select('adc_global_test', 'a')
        ->fields('a', array('global_var'))
        ->condition('index', $i, '=')
        ->execute()->fetchAll();

我可以用什么代替 fetchAll 来获取不在数组中的记录。 我想要这个记录在一个变量中。就像我必须使用这个:-

$name = "adc".$id;

【问题讨论】:

  • 你使用什么样的数据库?

标签: php drupal drupal-7


【解决方案1】:

使用fetchField():

$id = db_select('adc_global_test', 'a')
  ->fields('a', array('global_var'))
  ->condition('index', $i, '=')
  ->execute()
  ->fetchField();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-02
    • 2021-12-26
    • 1970-01-01
    • 2019-09-29
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 2016-05-20
    相关资源
    最近更新 更多