doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.92k stars 2.51k forks source link

Proposal: Implement extra_lazy for collection->getKeys() #5758

Open mrVrAlex opened 8 years ago

mrVrAlex commented 8 years ago

Hi, Guys! I want propose make for all extra_lazy associations, something like this:

$sql = 'SELECT indexBy FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses);
return (array) $this->conn->fetchColumn($sql, $params, 0, $types);

This should return an array IDs by simple SQL instead loop (and hydrate!) all collection.

DHager commented 8 years ago

Makes sense, although I've avoided keyed-collections because AFAIK when you update items (or flush them to get an auto-generated ID) the association-keys may be stale or inconsistent.