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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
f98c414c
Commit
f98c414c
authored
May 15, 2014
by
Fourteenmeister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update QueryBuilder.php
solution used **heukirne** for the names of columns.
parent
f46c7060
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
QueryBuilder.php
framework/db/mssql/QueryBuilder.php
+6
-5
No files found.
framework/db/mssql/QueryBuilder.php
View file @
f98c414c
...
...
@@ -197,7 +197,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
$select
=
$query
->
select
=
'*'
;
}
if
(
$select
===
'*'
)
{
$columns
=
$this
->
getAllColumnNames
(
$query
->
from
[
0
]
);
$columns
=
$this
->
getAllColumnNames
(
$query
->
modelClass
);
if
(
$columns
&&
is_array
(
$columns
))
$select
=
implode
(
', '
,
$columns
);
else
...
...
@@ -209,13 +209,14 @@ class QueryBuilder extends \yii\db\QueryBuilder
return
$sql
;
}
protected
function
getAllColumnNames
(
$
table
=
null
)
protected
function
getAllColumnNames
(
$
modelClass
=
null
)
{
if
(
!
$
table
)
{
if
(
!
$
modelClass
)
{
return
null
;
}
$columns
=
$this
->
db
->
createCommand
(
"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='
{
$table
}
'"
)
->
queryColumn
();
array_walk
(
$columns
,
create_function
(
'&$str'
,
'$str = "[$str]";'
));
$model
=
new
$modelClass
;
$schema
=
$model
->
getTableSchema
();
$columns
=
array_keys
(
$schema
->
columns
);
return
$columns
;
}
...
...
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