associative fix for #156#162
Closed
Surt wants to merge 3 commits intoj4mie:regression.find_many_id_keysfrom
Closed
associative fix for #156#162Surt wants to merge 3 commits intoj4mie:regression.find_many_id_keysfrom
Surt wants to merge 3 commits intoj4mie:regression.find_many_id_keysfrom
Conversation
…or a ORM instance.
… associative methods) AND there is a primary key defined in the result.
Contributor
Author
|
With this commits is easy to fix the |
Contributor
Author
|
We must change in https://github.com/j4mie/paris/blob/master/paris.php#L128 /**
* Create instances of each row in the result and map
* them to an associative array with the primary IDs as
* the array keys.
* @param array $rows
* @return array
*/
protected function _instances_with_id_as_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}) && $this->_associative_results) ? $row->{$this->_instance_id_column} : $i;
$instances[$key] = $row;
}
return $instances;
}And the last change, in Model, https://github.com/j4mie/paris/blob/master/paris.php#L388 ->where("{$join_table_name}.{$key_to_base_table}", $this->$base_table_id_column)
->non_associative();Until this patchs, Paris is broken on has_ |
Collaborator
|
See issue #133 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#156
What I did is:
non_associative,associative,reset_associativeself::$_config[$this->_connection_name]['find_many_primary_id_as_key']find_manycheck :non_associative,associative,reset_associative)So, the config dictates the behaviour to return or not associative keys. That behaviour could be changed during fluent query. If there isn't a primary key define it fallbacks to non associative result set.