Zend查询构建器:我需要根据用户对组的成员身份获取用户的显示名称

I am looking to get only the display name of a user if they belong to the group with id of 181. I have written a standard sequel code that does this, but I am really having trouble converting it into a working Zend version.

$stmt = $userTable->select()
  ->setIntegrityCheck(false)
  ->from( array('u' => $userTable->info('name')))
  ->joinLeft( array('gm' => $membershipTable->info('name')), 'gm.user_id = u.user_id')
  ->joinLeft(array('g' => $groupsTable->info('name')), 'g.group_id = gm.resource_id')
  ->columns('u.displayname')
  ->where('g.group_id = ?', 181);

$result = $userTable->getAdapter()->fetchAll($stmt);

Instead of returning the small data set I want, it returns the equivalent of a SELECT *.

Any help would be greatly appreciated. Thanks in advance.

You can do easily by adding the column name in the array.

$stmt = $userTable->select()
  ->setIntegrityCheck(false)
  ->from( array('u' => $userTable->info('name')),array('u.username'))
  ->joinLeft( array('gm' => $membershipTable->info('name')), 'gm.user_id = u.user_id')
  ->joinLeft(array('g' => $groupsTable->info('name')), 'g.group_id = gm.resource_id')
  ->columns('u.displayname')
  ->where('g.group_id = ?', 181);

$result = $userTable->getAdapter()->fetchAll($stmt);

If you dnt need any column than you can do this way.

->joinLeft( array('gm' => $membershipTable->info('name')), 'gm.user_id = u.user_id',array())