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
01465966
Commit
01465966
authored
Oct 29, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add relationClassName to AR to allow different relation classes
... for different dbms
parent
46535262
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
ActiveRecord.php
framework/yii/db/ActiveRecord.php
+8
-4
No files found.
framework/yii/db/ActiveRecord.php
View file @
01465966
...
@@ -93,6 +93,10 @@ class ActiveRecord extends Model
...
@@ -93,6 +93,10 @@ class ActiveRecord extends Model
const
OP_ALL
=
0x07
;
const
OP_ALL
=
0x07
;
/**
/**
* @var string the name of the class to use for relations.
*/
protected
$relationClassName
=
'yii\\db\\ActiveRelation'
;
/**
* @var array attribute values indexed by attribute names
* @var array attribute values indexed by attribute names
*/
*/
private
$_attributes
=
[];
private
$_attributes
=
[];
...
@@ -384,7 +388,7 @@ class ActiveRecord extends Model
...
@@ -384,7 +388,7 @@ class ActiveRecord extends Model
return
$this
->
_related
[
$t
];
return
$this
->
_related
[
$t
];
}
}
$value
=
parent
::
__get
(
$name
);
$value
=
parent
::
__get
(
$name
);
if
(
$value
instanceof
ActiveRelation
)
{
if
(
$value
instanceof
$this
->
relationClassName
)
{
return
$this
->
_related
[
$t
]
=
$value
->
multiple
?
$value
->
all
()
:
$value
->
one
();
return
$this
->
_related
[
$t
]
=
$value
->
multiple
?
$value
->
all
()
:
$value
->
one
();
}
else
{
}
else
{
return
$value
;
return
$value
;
...
@@ -474,7 +478,7 @@ class ActiveRecord extends Model
...
@@ -474,7 +478,7 @@ class ActiveRecord extends Model
*/
*/
public
function
hasOne
(
$class
,
$link
)
public
function
hasOne
(
$class
,
$link
)
{
{
return
new
ActiveRelation
([
return
new
$this
->
relationClassName
([
'modelClass'
=>
$class
,
'modelClass'
=>
$class
,
'primaryModel'
=>
$this
,
'primaryModel'
=>
$this
,
'link'
=>
$link
,
'link'
=>
$link
,
...
@@ -512,7 +516,7 @@ class ActiveRecord extends Model
...
@@ -512,7 +516,7 @@ class ActiveRecord extends Model
*/
*/
public
function
hasMany
(
$class
,
$link
)
public
function
hasMany
(
$class
,
$link
)
{
{
return
new
ActiveRelation
([
return
new
$this
->
relationClassName
([
'modelClass'
=>
$class
,
'modelClass'
=>
$class
,
'primaryModel'
=>
$this
,
'primaryModel'
=>
$this
,
'link'
=>
$link
,
'link'
=>
$link
,
...
@@ -1264,7 +1268,7 @@ class ActiveRecord extends Model
...
@@ -1264,7 +1268,7 @@ class ActiveRecord extends Model
$getter
=
'get'
.
$name
;
$getter
=
'get'
.
$name
;
try
{
try
{
$relation
=
$this
->
$getter
();
$relation
=
$this
->
$getter
();
if
(
$relation
instanceof
ActiveRelation
)
{
if
(
$relation
instanceof
$this
->
relationClassName
)
{
return
$relation
;
return
$relation
;
}
}
}
catch
(
UnknownMethodException
$e
)
{
}
catch
(
UnknownMethodException
$e
)
{
...
...
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