Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
8a687053
Commit
8a687053
authored
Apr 05, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
fix conflicts.
parents
ee288a77
b7ac1b75
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
15 deletions
+48
-15
artisan
artisan
+1
-1
query.php
laravel/database/eloquent/query.php
+33
-12
changes.md
laravel/documentation/changes.md
+12
-0
paths.php
paths.php
+1
-1
index.php
public/index.php
+1
-1
No files found.
artisan
View file @
8a687053
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans
*
*
* @package Laravel
* @package Laravel
* @version 3.1.
5
* @version 3.1.
6
* @author Taylor Otwell <taylorotwell@gmail.com>
* @author Taylor Otwell <taylorotwell@gmail.com>
* @link http://laravel.com
* @link http://laravel.com
*/
*/
...
...
laravel/database/eloquent/query.php
View file @
8a687053
<?php
namespace
Laravel\Database\Eloquent
;
use
Laravel\Database
;
<?php
namespace
Laravel\Database\Eloquent
;
use
Laravel\Database
;
use
Laravel\Database\Eloquent\Relationships\Has_Many_And_Belongs_To
;
class
Query
{
class
Query
{
...
@@ -54,7 +57,7 @@ class Query {
...
@@ -54,7 +57,7 @@ class Query {
*/
*/
public
function
first
(
$columns
=
array
(
'*'
))
public
function
first
(
$columns
=
array
(
'*'
))
{
{
$results
=
$this
->
hydrate
(
$this
->
model
,
$this
->
table
->
take
(
1
)
->
get
(
$columns
,
false
));
$results
=
$this
->
hydrate
(
$this
->
model
,
$this
->
table
->
take
(
1
)
->
get
(
$columns
));
return
(
count
(
$results
)
>
0
)
?
head
(
$results
)
:
null
;
return
(
count
(
$results
)
>
0
)
?
head
(
$results
)
:
null
;
}
}
...
@@ -63,12 +66,12 @@ class Query {
...
@@ -63,12 +66,12 @@ class Query {
* Get all of the model results for the query.
* Get all of the model results for the query.
*
*
* @param array $columns
* @param array $columns
* @param bool $
include
* @param bool $
keyed
* @return array
* @return array
*/
*/
public
function
get
(
$columns
=
array
(
'*'
),
$
include
=
true
)
public
function
get
(
$columns
=
array
(
'*'
),
$
keyed
=
true
)
{
{
return
$this
->
hydrate
(
$this
->
model
,
$this
->
table
->
get
(
$columns
),
$
include
);
return
$this
->
hydrate
(
$this
->
model
,
$this
->
table
->
get
(
$columns
),
$
keyed
);
}
}
/**
/**
...
@@ -97,9 +100,10 @@ class Query {
...
@@ -97,9 +100,10 @@ class Query {
*
*
* @param Model $model
* @param Model $model
* @param array $results
* @param array $results
* @param bool $keyed
* @return array
* @return array
*/
*/
public
function
hydrate
(
$model
,
$results
,
$
include
=
true
)
public
function
hydrate
(
$model
,
$results
,
$
keyed
=
true
)
{
{
$class
=
get_class
(
$model
);
$class
=
get_class
(
$model
);
...
@@ -124,10 +128,20 @@ class Query {
...
@@ -124,10 +128,20 @@ class Query {
$new
->
original
=
$new
->
attributes
;
$new
->
original
=
$new
->
attributes
;
$models
[
$result
[
$this
->
model
->
key
()]]
=
$new
;
// Typically, the resulting models are keyed by their primary key, but it
// may be useful to not do this in some circumstances such as when we
// are eager loading a *-to-* relationships which has duplicates.
if
(
$keyed
)
{
$models
[
$result
[
$this
->
model
->
key
()]]
=
$new
;
}
else
{
$models
[]
=
$new
;
}
}
}
if
(
$include
and
count
(
$results
)
>
0
)
if
(
count
(
$results
)
>
0
)
{
{
foreach
(
$this
->
model_includes
()
as
$relationship
=>
$constraints
)
foreach
(
$this
->
model_includes
()
as
$relationship
=>
$constraints
)
{
{
...
@@ -183,12 +197,19 @@ class Query {
...
@@ -183,12 +197,19 @@ class Query {
$query
->
table
->
where_nested
(
$constraints
);
$query
->
table
->
where_nested
(
$constraints
);
}
}
// Before matching the models, we will initialize the relationships
// to either null for single-value relationships or an array for
// the multi-value relationships as their baseline value.
$query
->
initialize
(
$results
,
$relationship
);
$query
->
initialize
(
$results
,
$relationship
);
$query
->
match
(
$relationship
,
$results
,
$query
->
get
());
// If we're eager loading a many-to-many relationship we will disable
// the primary key indexing on the hydration since there could be
// roles shared across users and we don't want to overwrite.
if
(
!
$query
instanceof
Has_Many_And_Belongs_To
)
{
$query
->
match
(
$relationship
,
$results
,
$query
->
get
());
}
else
{
$query
->
match
(
$relationship
,
$results
,
$query
->
get
(
array
(
'*'
),
false
));
}
}
}
/**
/**
...
...
laravel/documentation/changes.md
View file @
8a687053
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
-
[
Laravel 3.2
](
#3.2
)
-
[
Laravel 3.2
](
#3.2
)
-
[
Upgrading From 3.1
](
#upgrade-3.2
)
-
[
Upgrading From 3.1
](
#upgrade-3.2
)
-
[
Laravel 3.1.6
](
#3.1.6
)
-
[
Upgrading From 3.1.5
](
#upgrade-3.1.6
)
-
[
Laravel 3.1.5
](
#3.1.5
)
-
[
Laravel 3.1.5
](
#3.1.5
)
-
[
Upgrading From 3.1.4
](
#upgrade-3.1.5
)
-
[
Upgrading From 3.1.4
](
#upgrade-3.1.5
)
-
[
Laravel 3.1.4
](
#3.1.4
)
-
[
Laravel 3.1.4
](
#3.1.4
)
...
@@ -37,6 +39,16 @@
...
@@ -37,6 +39,16 @@
-
Replace the
**laravel**
folder.
-
Replace the
**laravel**
folder.
<a
name=
"3.1.6"
></a>
## Laravel 3.1.6
-
Fixes many-to-many eager loading in Eloquent.
<a
name=
"upgrade-3.1.6"
></a>
## Upgrading From 3.1.5
-
Replace the
**laravel**
folder.
<a
name=
"3.1.5"
></a>
<a
name=
"3.1.5"
></a>
## Laravel 3.1.5
## Laravel 3.1.5
...
...
paths.php
View file @
8a687053
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans
*
*
* @package Laravel
* @package Laravel
* @version 3.1.
5
* @version 3.1.
6
* @author Taylor Otwell <taylorotwell@gmail.com>
* @author Taylor Otwell <taylorotwell@gmail.com>
* @link http://laravel.com
* @link http://laravel.com
*/
*/
...
...
public/index.php
View file @
8a687053
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans
*
*
* @package Laravel
* @package Laravel
* @version 3.1.
5
* @version 3.1.
6
* @author Taylor Otwell <taylorotwell@gmail.com>
* @author Taylor Otwell <taylorotwell@gmail.com>
* @link http://laravel.com
* @link http://laravel.com
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment