Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
PSDI Army
yii2
Commits
a23c54ac
Commit
a23c54ac
authored
Nov 07, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made relation names in AR case sensitive
parent
90839ceb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
28 deletions
+7
-28
ActiveRecord.php
framework/yii/db/ActiveRecord.php
+7
-28
No files found.
framework/yii/db/ActiveRecord.php
View file @
a23c54ac
...
...
@@ -528,7 +528,7 @@ class ActiveRecord extends Model
*/
public
function
populateRelation
(
$name
,
$records
)
{
$this
->
_related
[
strtolower
(
$name
)
]
=
$records
;
$this
->
_related
[
$name
]
=
$records
;
}
/**
...
...
@@ -538,23 +538,7 @@ class ActiveRecord extends Model
*/
public
function
isRelationPopulated
(
$name
)
{
return
array_key_exists
(
strtolower
(
$name
),
$this
->
_related
);
}
/**
* @return array list of populated relation names
*/
public
function
getPopulatedRelationNames
()
{
$relations
=
array_keys
(
$this
->
_related
);
$reflection
=
new
\ReflectionClass
(
$this
);
foreach
(
$relations
as
$i
=>
$relation
)
{
if
(
$reflection
->
hasMethod
(
'get'
.
$relation
))
{
$method
=
$reflection
->
getMethod
(
'get'
.
$relation
);
$relations
[
$i
]
=
lcfirst
(
substr
(
$method
->
name
,
3
));
}
}
return
$relations
;
return
array_key_exists
(
$name
,
$this
->
_related
);
}
/**
...
...
@@ -562,12 +546,7 @@ class ActiveRecord extends Model
*/
public
function
getPopulatedRelations
()
{
$relations
=
$this
->
getPopulatedRelationNames
();
$data
=
[];
foreach
(
$relations
as
$name
)
{
$data
[
$name
]
=
$this
->
_related
[
strtolower
(
$name
)];
}
return
$data
;
return
$this
->
_related
;
}
/**
...
...
@@ -1325,7 +1304,7 @@ class ActiveRecord extends Model
*
* Note that this method requires that the primary key value is not null.
*
* @param string $name the name of the relationship
* @param string $name the
case sensitive
name of the relationship
* @param ActiveRecord $model the model to be linked with the current one.
* @param array $extraColumns additional column values to be saved into the pivot table.
* This parameter is only meaningful for a relationship involving a pivot table
...
...
@@ -1347,7 +1326,7 @@ class ActiveRecord extends Model
$viaClass
=
$viaRelation
->
modelClass
;
$viaTable
=
$viaClass
::
tableName
();
// unset $viaName so that it can be reloaded to reflect the change
unset
(
$this
->
_related
[
strtolower
(
$viaName
)
]);
unset
(
$this
->
_related
[
$viaName
]);
}
else
{
$viaRelation
=
$relation
->
via
;
$viaTable
=
reset
(
$relation
->
via
->
from
);
...
...
@@ -1403,7 +1382,7 @@ class ActiveRecord extends Model
* The model with the foreign key of the relationship will be deleted if `$delete` is true.
* Otherwise, the foreign key will be set null and the model will be saved without validation.
*
* @param string $name the name of the relationship.
* @param string $name the
case sensitive
name of the relationship.
* @param ActiveRecord $model the model to be unlinked from the current one.
* @param boolean $delete whether to delete the model that contains the foreign key.
* If false, the model's foreign key will be set null and saved.
...
...
@@ -1421,7 +1400,7 @@ class ActiveRecord extends Model
/** @var $viaClass ActiveRecord */
$viaClass
=
$viaRelation
->
modelClass
;
$viaTable
=
$viaClass
::
tableName
();
unset
(
$this
->
_related
[
strtolower
(
$viaName
)
]);
unset
(
$this
->
_related
[
$viaName
]);
}
else
{
$viaRelation
=
$relation
->
via
;
$viaTable
=
reset
(
$relation
->
via
->
from
);
...
...
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