-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improvement] find_many returns rows with keys equal to the "id" defined, if exists #132
Comments
A new change for Paris, related to the change in Idiorm. protected function _instances_with_key($rows){
$size = count($rows);
$instances = array();
for ($i = 0; $i < $size; $i++) {
$row = $this->_create_instance_from_row($rows[$i]);
$row = $this->_create_model_instance($row);
$key = (isset($row->{$this->_instance_id_column})) ? $row->{$this->_instance_id_column} : $i;
$instances[$key] = $row;
}
return $instances;
} |
Thanks to the associative keys change, resultsets can use the keys to build, for example, a query to delete all, in just 1 query, or update... instead of call the function on each model. |
Nice! I'd like to use this feature on my current project. Sorry if this is a little off-topic, but, when is the next point release expected? |
@lrlopez It was going to be this week, but I am snowed under with a client project at the moment. I am still aiming to have 1.4 out in June though. |
With this change, the find_many will return an array, or resultSet, with keys as the primary key.
array(
'4' => 'aModelinstance'...
'20' => 'anotherModelinstance'...
);
It will save time for the eagerLoading functionality we are preparing for Paris.
The text was updated successfully, but these errors were encountered: