Reputation: 85
When I do something like this:
$boards = Doctrine_Query::create()
->select('bds.id')
->from('board bds')
->whereIn('bds.type', $boardtype)
->orderBy('bds.id')
->execute();
the result $boards has more fields (columns) than what I wanted. All I wanted was just a single array of table Board column Id. Is there a way to do that?
I wanted to use the array in something like the following:
$buildings = Doctrine_Core::getTable('building')->createQuery('a')
->WhereIn('a.board_id', $boards)
->orderBy('a.id')
->execute();
However WhereIn only takes an array but not a query, so now I have to loop through $boards and generate an array of ID for WhereIn.
Therefore, I was wondering if I can retrieve a column as an array? or if there is an alternative for what I'm doing. Thank you for any help.
Background info:
Board has an many to one relationship with Building. Id (key) column of Board is related to board_id column in Building.
What I want to achieve is generate a query of buildings that are associated with boards of given board types.
Upvotes: 0
Views: 153
Reputation: 1284
You should read : 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);
Upvotes: 1