我有一个表voting_nomination_counter
,其中有4列。我需要获取列uid
的所有值。我正努力做到这一点:
$sql = db_select('voting_nomination_counter', 'v')
->fields('v', array('uid'))
->execute()
->fetchAssoc();
$user_id = array();
foreach ($sql as $item) {
$user_id[] = $item;
}
但只返回一个值。怎么了?
答案 0 :(得分:0)
$sql = db_select('voting_nomination_counter', 'v')
->fields('v', array('uid'))
->execute()
->fetchAssoc();
删除fetchAssoc()并将其写为:
$sql = db_select('voting_nomination_counter', 'v')
->fields('v', array('uid'))
->execute();
或
$sql = db_select('voting_nomination_counter', 'v')
->fields('v', array('uid'))
->execute()
->fetchAll();