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
1654381a
Commit
1654381a
authored
Jan 05, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support table aliases for ActiveQuery::joinWith().
parent
e050aeac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
ActiveQuery.php
framework/yii/db/ActiveQuery.php
+15
-14
No files found.
framework/yii/db/ActiveQuery.php
View file @
1654381a
...
@@ -326,19 +326,27 @@ class ActiveQuery extends Query implements ActiveQueryInterface
...
@@ -326,19 +326,27 @@ class ActiveQuery extends Query implements ActiveQueryInterface
}
}
/**
/**
* Returns the table
name used by the specified active query
.
* Returns the table
alias (or table name) that can be used to prefix column names
.
* @param ActiveQuery $query
* @param ActiveQuery $query
* @return string the table
name
* @return string the table
alias (or table name) enclosed within double curly brackets.
*/
*/
private
function
getQueryTable
Name
(
$query
)
private
function
getQueryTable
Alias
(
$query
)
{
{
if
(
empty
(
$query
->
from
))
{
if
(
empty
(
$query
->
from
))
{
/** @var ActiveRecord $modelClass */
/** @var ActiveRecord $modelClass */
$modelClass
=
$query
->
modelClass
;
$modelClass
=
$query
->
modelClass
;
return
$modelClass
::
tableName
();
$tableName
=
$modelClass
::
tableName
();
}
else
{
}
else
{
return
reset
(
$query
->
from
);
$tableName
=
reset
(
$query
->
from
);
}
if
(
preg_match
(
'/^(.*?)\s+({{\w+}}|\w+)$/'
,
$tableName
,
$matches
))
{
$tableName
=
$matches
[
2
];
}
if
(
strpos
(
$tableName
,
'{{'
)
===
false
)
{
$tableName
=
'{{'
.
$tableName
.
'}}'
;
}
}
return
$tableName
;
}
}
/**
/**
...
@@ -364,15 +372,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
...
@@ -364,15 +372,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
return
;
return
;
}
}
$parentTable
=
$this
->
getQueryTableName
(
$parent
);
$parentTable
=
$this
->
getQueryTableAlias
(
$parent
);
$childTable
=
$this
->
getQueryTableName
(
$child
);
$childTable
=
$this
->
getQueryTableAlias
(
$child
);
if
(
strpos
(
$parentTable
,
'{{'
)
===
false
)
{
$parentTable
=
'{{'
.
$parentTable
.
'}}'
;
}
if
(
strpos
(
$childTable
,
'{{'
)
===
false
)
{
$childTable
=
'{{'
.
$childTable
.
'}}'
;
}
if
(
!
empty
(
$child
->
link
))
{
if
(
!
empty
(
$child
->
link
))
{
$on
=
[];
$on
=
[];
...
...
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