Skip to content

Commit

Permalink
increment version. refactor eloquent eager loading matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 7, 2012
1 parent 1df8fa9 commit 3416506
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion artisan
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @version 3.2.10
* @version 3.2.11
* @author Taylor Otwell <[email protected]>
* @link http://laravel.com
*/
Expand Down
9 changes: 5 additions & 4 deletions laravel/database/eloquent/relationships/belongs_to.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,18 @@ public function match($relationship, &$children, $parents)
{
$foreign = $this->foreign_key();

$parents_hash = array();
$dictionary = array();

foreach ($parents as $parent)
{
$parents_hash[$parent->get_key()] = $parent;
$dictionary[$parent->get_key()] = $parent;
}

foreach ($children as $child)
{
if (array_key_exists($child->$foreign, $parents_hash))
if (array_key_exists($child->$foreign, $dictionary))
{
$child->relationships[$relationship] = $parents_hash[$child->$foreign];
$child->relationships[$relationship] = $dictionary[$child->$foreign];
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions laravel/database/eloquent/relationships/has_many.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,18 @@ public function match($relationship, &$parents, $children)
{
$foreign = $this->foreign_key();

$children_hash = array();
$dictionary = array();

foreach ($children as $child)
{
$children_hash[$child->$foreign][] = $child;
$dictionary[$child->$foreign][] = $child;
}

foreach ($parents as $parent)
{
if (array_key_exists($parent->get_key(), $children_hash))
if (array_key_exists($key = $parent->get_key(), $dictionary))
{
$parent->relationships[$relationship] = $children_hash[$parent->get_key()];
$parent->relationships[$relationship] = $dictionary[$key];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,18 @@ public function match($relationship, &$parents, $children)
{
$foreign = $this->foreign_key();

$children_hash = array();
$dictionary = array();

foreach ($children as $child)
{
$children_hash[$child->pivot->$foreign][] = $child;
$dictionary[$child->pivot->$foreign][] = $child;
}

foreach ($parents as $parent)
{
if (array_key_exists($parent->get_key(), $children_hash))
if (array_key_exists($key = $parent->get_key(), $dictionary))
{
$parent->relationships[$relationship] = $children_hash[$parent->get_key()];
$parent->relationships[$relationship] = $dictionary[$key];
}
}
}
Expand Down
14 changes: 5 additions & 9 deletions laravel/database/eloquent/relationships/has_one.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,18 @@ public function match($relationship, &$parents, $children)
{
$foreign = $this->foreign_key();

$children_hash = array();
$dictionary = array();

foreach ($children as $child)
{
if (array_key_exists($child->$foreign, $children_hash))
{
continue;
}

$children_hash[$child->$foreign] = $child;
$dictionary[$child->$foreign] = $child;
}

foreach ($parents as $parent)
{
if (array_key_exists($parent->get_key(), $children_hash))
if (array_key_exists($key = $parent->get_key(), $dictionary))
{
$parent->relationships[$relationship] = $children_hash[$parent->get_key()];
$parent->relationships[$relationship] = $dictionary[$key];
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions laravel/documentation/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Contents

- [Laravel 3.2.11](#3.2.11)
- [Upgrading From 3.2.10](#upgrade-3.2.11)
- [Laravel 3.2.10](#3.2.10)
- [Upgrading From 3.2.9](#upgrade-3.2.10)
- [Laravel 3.2.9](#3.2.9)
Expand Down Expand Up @@ -45,6 +47,16 @@
- [Laravel 3.1](#3.1)
- [Upgrading From 3.0](#upgrade-3.1)

<a name="3.2.11"></a>
## Laravel 3.2.11

- Improve performance of Eloquent eager load matching.

<a name="upgrade-3.2.11"></a>
### Upgrading From 3.2.10

- Replace the **laravel** folder.

<a name="3.2.10"></a>
## Laravel 3.2.10

Expand Down
2 changes: 1 addition & 1 deletion paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @version 3.2.10
* @version 3.2.11
* @author Taylor Otwell <[email protected]>
* @link http://laravel.com
*/
Expand Down
2 changes: 1 addition & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @version 3.2.10
* @version 3.2.11
* @author Taylor Otwell <[email protected]>
* @link http://laravel.com
*/
Expand Down

0 comments on commit 3416506

Please sign in to comment.