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
17a316cd
Commit
17a316cd
authored
May 24, 2013
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/yiisoft/yii2
into jui-tabs
parents
0f6a7080
3062029c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
128 additions
and
25 deletions
+128
-25
HelloController.php
apps/bootstrap/commands/HelloController.php
+2
-1
composer.json
apps/bootstrap/composer.json
+2
-2
composer.json
extensions/composer/composer.json
+1
-1
InstallHandler.php
extensions/composer/yii/composer/InstallHandler.php
+48
-4
Schema.php
framework/yii/db/mssql/Schema.php
+12
-12
Html.php
framework/yii/helpers/base/Html.php
+1
-1
Application.php
framework/yii/web/Application.php
+8
-1
mssql.sql
tests/unit/data/mssql.sql
+1
-1
MssqlCommandTest.php
tests/unit/framework/db/mssql/MssqlCommandTest.php
+53
-2
No files found.
apps/bootstrap/commands/HelloController.php
View file @
17a316cd
...
@@ -24,6 +24,6 @@ class HelloController extends Controller
...
@@ -24,6 +24,6 @@ class HelloController extends Controller
*/
*/
public
function
actionIndex
(
$message
=
'hello world'
)
public
function
actionIndex
(
$message
=
'hello world'
)
{
{
echo
$message
;
echo
$message
.
"
\n
"
;
}
}
}
}
\ No newline at end of file
apps/bootstrap/composer.json
View file @
17a316cd
...
@@ -27,11 +27,11 @@
...
@@ -27,11 +27,11 @@
]
]
},
},
"extra"
:
{
"extra"
:
{
"writable"
:
[
"
yii-install-
writable"
:
[
"runtime"
,
"runtime"
,
"www/assets"
"www/assets"
],
],
"executable"
:
[
"
yii-install-
executable"
:
[
"yii"
"yii"
]
]
}
}
...
...
extensions/composer/composer.json
View file @
17a316cd
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
],
],
"minimum-stability"
:
"dev"
,
"minimum-stability"
:
"dev"
,
"require"
:
{
"require"
:
{
"yiisoft/yii2"
:
"
dev-master
"
"yiisoft/yii2"
:
"
*
"
},
},
"autoload"
:
{
"autoload"
:
{
"psr-0"
:
{
"yii
\\
composer"
:
""
}
"psr-0"
:
{
"yii
\\
composer"
:
""
}
...
...
extensions/composer/yii/composer/InstallHandler.php
View file @
17a316cd
...
@@ -8,15 +8,28 @@
...
@@ -8,15 +8,28 @@
namespace
yii\composer
;
namespace
yii\composer
;
use
Composer\Script\CommandEvent
;
use
Composer\Script\CommandEvent
;
use
yii\console\Application
;
use
yii\console\Exception
;
defined
(
'YII_DEBUG'
)
or
define
(
'YII_DEBUG'
,
true
);
// fcgi doesn't have STDIN defined by default
defined
(
'STDIN'
)
or
define
(
'STDIN'
,
fopen
(
'php://stdin'
,
'r'
));
/**
/**
* InstallHandler is called by Composer after it installs/updates the current package.
* InstallHandler is called by Composer after it installs/updates the current package.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Tobias Munk <schmunk@usrbin.de>
* @since 2.0
* @since 2.0
*/
*/
class
InstallHandler
class
InstallHandler
{
{
const
PARAM_WRITABLE
=
'yii-install-writable'
;
const
PARAM_EXECUTABLE
=
'yii-install-executable'
;
const
PARAM_CONFIG
=
'yii-install-config'
;
const
PARAM_COMMANDS
=
'yii-install-commands'
;
/**
/**
* Sets the correct permissions of files and directories.
* Sets the correct permissions of files and directories.
* @param CommandEvent $event
* @param CommandEvent $event
...
@@ -24,11 +37,11 @@ class InstallHandler
...
@@ -24,11 +37,11 @@ class InstallHandler
public
static
function
setPermissions
(
$event
)
public
static
function
setPermissions
(
$event
)
{
{
$options
=
array_merge
(
array
(
$options
=
array_merge
(
array
(
'writable'
=>
array
(),
self
::
PARAM_WRITABLE
=>
array
(),
'executable'
=>
array
(),
self
::
PARAM_EXECUTABLE
=>
array
(),
),
$event
->
getComposer
()
->
getPackage
()
->
getExtra
());
),
$event
->
getComposer
()
->
getPackage
()
->
getExtra
());
foreach
((
array
)
$options
[
'writable'
]
as
$path
)
{
foreach
((
array
)
$options
[
self
::
PARAM_WRITABLE
]
as
$path
)
{
echo
"Setting writable:
$path
..."
;
echo
"Setting writable:
$path
..."
;
if
(
is_dir
(
$path
))
{
if
(
is_dir
(
$path
))
{
chmod
(
$path
,
0777
);
chmod
(
$path
,
0777
);
...
@@ -39,7 +52,7 @@ class InstallHandler
...
@@ -39,7 +52,7 @@ class InstallHandler
}
}
}
}
foreach
((
array
)
$options
[
'executable'
]
as
$path
)
{
foreach
((
array
)
$options
[
self
::
PARAM_EXECUTABLE
]
as
$path
)
{
echo
"Setting executable:
$path
..."
;
echo
"Setting executable:
$path
..."
;
if
(
is_file
(
$path
))
{
if
(
is_file
(
$path
))
{
chmod
(
$path
,
0755
);
chmod
(
$path
,
0755
);
...
@@ -50,4 +63,35 @@ class InstallHandler
...
@@ -50,4 +63,35 @@ class InstallHandler
}
}
}
}
}
}
/**
* Executes a yii command.
* @param CommandEvent $event
*/
public
static
function
run
(
$event
)
{
$options
=
array_merge
(
array
(
self
::
PARAM_COMMANDS
=>
array
(),
),
$event
->
getComposer
()
->
getPackage
()
->
getExtra
());
if
(
!
isset
(
$options
[
self
::
PARAM_CONFIG
]))
{
throw
new
Exception
(
'Please specify the "'
.
self
::
PARAM_CONFIG
.
'" parameter in composer.json.'
);
}
$configFile
=
getcwd
()
.
'/'
.
$options
[
self
::
PARAM_CONFIG
];
if
(
!
is_file
(
$configFile
))
{
throw
new
Exception
(
"Config file does not exist:
$configFile
"
);
}
require
(
__DIR__
.
'/../../../yii2/yii/Yii.php'
);
$application
=
new
Application
(
require
(
$configFile
));
$request
=
$application
->
getRequest
();
foreach
((
array
)
$options
[
self
::
PARAM_COMMANDS
]
as
$command
)
{
$params
=
str_getcsv
(
$command
,
' '
);
// see http://stackoverflow.com/a/6609509/291573
$request
->
setParams
(
$params
);
list
(
$route
,
$params
)
=
$request
->
resolve
();
echo
"Running command: yii
{
$command
}
\n
"
;
$application
->
runAction
(
$route
,
$params
);
}
}
}
}
framework/yii/db/mssql/Schema.php
View file @
17a316cd
...
@@ -156,14 +156,14 @@ class Schema extends \yii\db\Schema
...
@@ -156,14 +156,14 @@ class Schema extends \yii\db\Schema
{
{
$column
=
new
ColumnSchema
();
$column
=
new
ColumnSchema
();
$column
->
name
=
$info
[
'
COLUMN_NAME
'
];
$column
->
name
=
$info
[
'
column_name
'
];
$column
->
allowNull
=
$info
[
'
IS_NULLABLE
'
]
==
'YES'
;
$column
->
allowNull
=
$info
[
'
is_nullable
'
]
==
'YES'
;
$column
->
dbType
=
$info
[
'
DATA_TYPE
'
];
$column
->
dbType
=
$info
[
'
data_type
'
];
$column
->
enumValues
=
array
();
// mssql has only vague equivalents to enum
$column
->
enumValues
=
array
();
// mssql has only vague equivalents to enum
$column
->
isPrimaryKey
=
null
;
// primary key will be determined in findColumns() method
$column
->
isPrimaryKey
=
null
;
// primary key will be determined in findColumns() method
$column
->
autoIncrement
=
$info
[
'
IsI
dentity'
]
==
1
;
$column
->
autoIncrement
=
$info
[
'
is_i
dentity'
]
==
1
;
$column
->
unsigned
=
stripos
(
$column
->
dbType
,
'unsigned'
)
!==
false
;
$column
->
unsigned
=
stripos
(
$column
->
dbType
,
'unsigned'
)
!==
false
;
$column
->
comment
=
$info
[
'
Comment'
]
===
null
?
''
:
$column
[
'C
omment'
];
$column
->
comment
=
$info
[
'
comment'
]
===
null
?
''
:
$info
[
'c
omment'
];
$column
->
type
=
self
::
TYPE_STRING
;
$column
->
type
=
self
::
TYPE_STRING
;
if
(
preg_match
(
'/^(\w+)(?:\(([^\)]+)\))?/'
,
$column
->
dbType
,
$matches
))
{
if
(
preg_match
(
'/^(\w+)(?:\(([^\)]+)\))?/'
,
$column
->
dbType
,
$matches
))
{
...
@@ -191,11 +191,11 @@ class Schema extends \yii\db\Schema
...
@@ -191,11 +191,11 @@ class Schema extends \yii\db\Schema
$column
->
phpType
=
$this
->
getColumnPhpType
(
$column
);
$column
->
phpType
=
$this
->
getColumnPhpType
(
$column
);
if
(
$info
[
'
COLUMN_DEFAULT
'
]
==
'(NULL)'
)
{
if
(
$info
[
'
column_default
'
]
==
'(NULL)'
)
{
$info
[
'
COLUMN_DEFAULT
'
]
=
null
;
$info
[
'
column_default
'
]
=
null
;
}
}
if
(
$column
->
type
!==
'timestamp'
||
$info
[
'
COLUMN_DEFAULT
'
]
!==
'CURRENT_TIMESTAMP'
)
{
if
(
$column
->
type
!==
'timestamp'
||
$info
[
'
column_default
'
]
!==
'CURRENT_TIMESTAMP'
)
{
$column
->
defaultValue
=
$column
->
typecast
(
$info
[
'
COLUMN_DEFAULT
'
]);
$column
->
defaultValue
=
$column
->
typecast
(
$info
[
'
column_default
'
]);
}
}
return
$column
;
return
$column
;
...
@@ -221,9 +221,9 @@ class Schema extends \yii\db\Schema
...
@@ -221,9 +221,9 @@ class Schema extends \yii\db\Schema
$sql
=
<<<SQL
$sql
=
<<<SQL
SELECT
SELECT
[t1].
*
,
[t1].
[column_name], [t1].[is_nullable], [t1].[data_type], [t1].[column_default]
,
COLUMNPROPERTY(OBJECT_ID([t1].[table_schema] + '.' + [t1].[table_name]), [t1].[column_name], 'IsIdentity') AS
IsI
dentity,
COLUMNPROPERTY(OBJECT_ID([t1].[table_schema] + '.' + [t1].[table_name]), [t1].[column_name], 'IsIdentity') AS
is_i
dentity,
CONVERT(VARCHAR, [t2].[value]) AS
C
omment
CONVERT(VARCHAR, [t2].[value]) AS
c
omment
FROM {$columnsTableName} AS [t1]
FROM {$columnsTableName} AS [t1]
LEFT OUTER JOIN [sys].[extended_properties] AS [t2] ON
LEFT OUTER JOIN [sys].[extended_properties] AS [t2] ON
[t1].[ordinal_position] = [t2].[minor_id] AND
[t1].[ordinal_position] = [t2].[minor_id] AND
...
...
framework/yii/helpers/base/Html.php
View file @
17a316cd
...
@@ -1364,7 +1364,7 @@ class Html
...
@@ -1364,7 +1364,7 @@ class Html
return
Yii
::
$app
->
getRequest
()
->
getUrl
();
return
Yii
::
$app
->
getRequest
()
->
getUrl
();
}
else
{
}
else
{
$url
=
Yii
::
getAlias
(
$url
);
$url
=
Yii
::
getAlias
(
$url
);
if
(
$url
[
0
]
===
'/'
||
strpos
(
$url
,
'://'
))
{
if
(
$url
[
0
]
===
'/'
||
$url
[
0
]
===
'#'
||
strpos
(
$url
,
'://'
))
{
return
$url
;
return
$url
;
}
else
{
}
else
{
return
Yii
::
$app
->
getRequest
()
->
getBaseUrl
()
.
'/'
.
$url
;
return
Yii
::
$app
->
getRequest
()
->
getBaseUrl
()
.
'/'
.
$url
;
...
...
framework/yii/web/Application.php
View file @
17a316cd
...
@@ -8,6 +8,8 @@
...
@@ -8,6 +8,8 @@
namespace
yii\web
;
namespace
yii\web
;
use
Yii
;
use
Yii
;
use
yii\base\HttpException
;
use
yii\base\InvalidRouteException
;
/**
/**
* Application is the base class for all application classes.
* Application is the base class for all application classes.
...
@@ -25,6 +27,7 @@ class Application extends \yii\base\Application
...
@@ -25,6 +27,7 @@ class Application extends \yii\base\Application
/**
/**
* Processes the request.
* Processes the request.
* @return integer the exit status of the controller action (0 means normal, non-zero values mean abnormal)
* @return integer the exit status of the controller action (0 means normal, non-zero values mean abnormal)
* @throws HttpException if the request cannot be resolved.
*/
*/
public
function
processRequest
()
public
function
processRequest
()
{
{
...
@@ -32,7 +35,11 @@ class Application extends \yii\base\Application
...
@@ -32,7 +35,11 @@ class Application extends \yii\base\Application
Yii
::
setAlias
(
'@wwwroot'
,
dirname
(
$request
->
getScriptFile
()));
Yii
::
setAlias
(
'@wwwroot'
,
dirname
(
$request
->
getScriptFile
()));
Yii
::
setAlias
(
'@www'
,
$request
->
getBaseUrl
());
Yii
::
setAlias
(
'@www'
,
$request
->
getBaseUrl
());
list
(
$route
,
$params
)
=
$request
->
resolve
();
list
(
$route
,
$params
)
=
$request
->
resolve
();
return
$this
->
runAction
(
$route
,
$params
);
try
{
return
$this
->
runAction
(
$route
,
$params
);
}
catch
(
InvalidRouteException
$e
)
{
throw
new
HttpException
(
404
,
$e
->
getMessage
(),
$e
->
getCode
(),
$e
);
}
}
}
private
$_homeUrl
;
private
$_homeUrl
;
...
...
tests/unit/data/mssql.sql
View file @
17a316cd
...
@@ -62,7 +62,7 @@ CREATE TABLE [dbo].[tbl_type] (
...
@@ -62,7 +62,7 @@ CREATE TABLE [dbo].[tbl_type] (
[
char_col3
]
[
text
],
[
char_col3
]
[
text
],
[
float_col
]
[
decimal
](
4
,
3
)
NOT
NULL
,
[
float_col
]
[
decimal
](
4
,
3
)
NOT
NULL
,
[
float_col2
]
[
float
]
DEFAULT
'1.23'
,
[
float_col2
]
[
float
]
DEFAULT
'1.23'
,
[
blob_col
]
[
binary
]
,
[
blob_col
]
[
varbinary
](
MAX
)
,
[
numeric_col
]
[
decimal
](
5
,
2
)
DEFAULT
'33.22'
,
[
numeric_col
]
[
decimal
](
5
,
2
)
DEFAULT
'33.22'
,
[
time
]
[
datetime
]
NOT
NULL
DEFAULT
'2002-01-01 00:00:00'
,
[
time
]
[
datetime
]
NOT
NULL
DEFAULT
'2002-01-01 00:00:00'
,
[
bool_col
]
[
tinyint
]
NOT
NULL
,
[
bool_col
]
[
tinyint
]
NOT
NULL
,
...
...
tests/unit/framework/db/mssql/MssqlCommandTest.php
View file @
17a316cd
...
@@ -21,11 +21,62 @@ class MssqlCommandTest extends \yiiunit\framework\db\CommandTest
...
@@ -21,11 +21,62 @@ class MssqlCommandTest extends \yiiunit\framework\db\CommandTest
function
testPrepareCancel
()
function
testPrepareCancel
()
{
{
$this
->
markTest
Incomplete
(
);
$this
->
markTest
Skipped
(
'MSSQL driver does not support this feature.'
);
}
}
function
testBindParamValue
()
function
testBindParamValue
()
{
{
$this
->
markTestIncomplete
();
$db
=
$this
->
getConnection
();
// bindParam
$sql
=
'INSERT INTO tbl_customer(email, name, address) VALUES (:email, :name, :address)'
;
$command
=
$db
->
createCommand
(
$sql
);
$email
=
'user4@example.com'
;
$name
=
'user4'
;
$address
=
'address4'
;
$command
->
bindParam
(
':email'
,
$email
);
$command
->
bindParam
(
':name'
,
$name
);
$command
->
bindParam
(
':address'
,
$address
);
$command
->
execute
();
$sql
=
'SELECT name FROM tbl_customer WHERE email=:email'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindParam
(
':email'
,
$email
);
$this
->
assertEquals
(
$name
,
$command
->
queryScalar
());
$sql
=
'INSERT INTO tbl_type (int_col, char_col, float_col, blob_col, numeric_col, bool_col) VALUES (:int_col, :char_col, :float_col, CONVERT([varbinary], :blob_col), :numeric_col, :bool_col)'
;
$command
=
$db
->
createCommand
(
$sql
);
$intCol
=
123
;
$charCol
=
'abc'
;
$floatCol
=
1.23
;
$blobCol
=
"
\x10\x11\x12
"
;
$numericCol
=
'1.23'
;
$boolCol
=
false
;
$command
->
bindParam
(
':int_col'
,
$intCol
);
$command
->
bindParam
(
':char_col'
,
$charCol
);
$command
->
bindParam
(
':float_col'
,
$floatCol
);
$command
->
bindParam
(
':blob_col'
,
$blobCol
);
$command
->
bindParam
(
':numeric_col'
,
$numericCol
);
$command
->
bindParam
(
':bool_col'
,
$boolCol
);
$this
->
assertEquals
(
1
,
$command
->
execute
());
$sql
=
'SELECT int_col, char_col, float_col, CONVERT([nvarchar], blob_col) AS blob_col, numeric_col FROM tbl_type'
;
$row
=
$db
->
createCommand
(
$sql
)
->
queryRow
();
$this
->
assertEquals
(
$intCol
,
$row
[
'int_col'
]);
$this
->
assertEquals
(
$charCol
,
trim
(
$row
[
'char_col'
]));
$this
->
assertEquals
(
$floatCol
,
$row
[
'float_col'
]);
$this
->
assertEquals
(
$blobCol
,
$row
[
'blob_col'
]);
$this
->
assertEquals
(
$numericCol
,
$row
[
'numeric_col'
]);
// bindValue
$sql
=
'INSERT INTO tbl_customer(email, name, address) VALUES (:email, \'user5\', \'address5\')'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindValue
(
':email'
,
'user5@example.com'
);
$command
->
execute
();
$sql
=
'SELECT email FROM tbl_customer WHERE name=:name'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindValue
(
':name'
,
'user5'
);
$this
->
assertEquals
(
'user5@example.com'
,
$command
->
queryScalar
());
}
}
}
}
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