mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Column Hydrator #5002
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @inssein on GitHub (Feb 4, 2016).
Originally assigned to: @Ocramius on GitHub.
I quickly wanted to get a column's value from the database, and realized there was no good way of returning the data.
Array Hydrator:
Output:
[['prop' => 'x'], ['prop' => 'y']]The desired output in this given scenario for me, would be
['x', 'y'], and that would be super easy with a Column Hydrator ($this->_stmt->fetchAll(PDO::FETCH_COLUMN);).Should I submit this as a PR? I am not sure if there has been a previous discussion around this subject, but I didn't find any from a quick glance.
@Ocramius commented on GitHub (Feb 4, 2016):
@inssein simply:
array_columnalso does this ;-)A new hydrator for this sort of functionality is unnecessary.
@inssein commented on GitHub (Feb 4, 2016):
@Ocramius yeah, that's what I have been doing previously, but I think I have done it enough times that it made sense to do it as a Hydrator. Just thought I'd contribute it back, but no worries.
@Ocramius commented on GitHub (Feb 4, 2016):
@inssein calling
array_columnor configuring a custom hydrator is the same amount of effort: I wouldn't add a new hydrator for something this trivial, as it just increases the amount of code in the library for no strong reason ;-)@inssein commented on GitHub (Feb 4, 2016):
sounds good.