当我做这样的事情时:
$boards = Doctrine_Query::create()
->select('bds.id')
->from('board bds')
->whereIn('bds.type', $boardtype)
->orderBy('bds.id')
->execute();
结果$ boards有比我想要的更多的字段(列)。我想要的只是一个表单板列Id的单个数组。有没有办法做到这一点?
我想在以下内容中使用数组:
$buildings = Doctrine_Core::getTable('building')->createQuery('a')
->WhereIn('a.board_id', $boards)
->orderBy('a.id')
->execute();
然而,WhereIn只接受一个数组而不是一个查询,所以现在我必须遍历$ boards并为WhereIn生成一个ID数组。
因此,我想知道我是否可以将列检索为数组?或者如果我正在做什么的替代方案。谢谢你的帮助。
背景资料:
董事会与Building建立了多对一的关系。 Board的Id(key)列与Building中的board_id列相关
我想要实现的是生成与给定板类型的板相关联的建筑物的查询。
答案 0 :(得分:1)
您应该阅读:http://www.doctrine-project.org/documentation/manual/1_2/en/data-hydrators
$boards = Doctrine_Query::create()
->select('bds.id')
->from('board bds')
->whereIn('bds.type', $boardtype)
->orderBy('bds.id')
->execute(array(), Doctrine_Core::HYDRATE_SINGLE_SCALAR);