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
d15378ef
Commit
d15378ef
authored
Jan 05, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved db tests.
parent
2188ece1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
121 deletions
+121
-121
ActiveRecord.php
framework/db/ActiveRecord.php
+10
-11
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+1
-1
CommandTest.php
tests/unit/framework/db/CommandTest.php
+108
-1
ConnectionTest.php
tests/unit/framework/db/ConnectionTest.php
+1
-1
QueryTest.php
tests/unit/framework/db/QueryTest.php
+1
-107
No files found.
framework/db/ActiveRecord.php
View file @
d15378ef
...
@@ -189,9 +189,9 @@ abstract class ActiveRecord extends Model
...
@@ -189,9 +189,9 @@ abstract class ActiveRecord extends Model
*/
*/
public
static
function
updateAll
(
$attributes
,
$condition
=
''
,
$params
=
array
())
public
static
function
updateAll
(
$attributes
,
$condition
=
''
,
$params
=
array
())
{
{
$
query
=
new
Query
;
$
command
=
static
::
getDbConnection
()
->
createCommand
()
;
$
query
->
update
(
static
::
tableName
(),
$attributes
,
$condition
,
$params
);
$
command
->
update
(
static
::
tableName
(),
$attributes
,
$condition
,
$params
);
return
$
query
->
createCommand
(
static
::
getDbConnection
())
->
execute
();
return
$
command
->
execute
();
}
}
/**
/**
...
@@ -210,9 +210,9 @@ abstract class ActiveRecord extends Model
...
@@ -210,9 +210,9 @@ abstract class ActiveRecord extends Model
$quotedName
=
$db
->
quoteColumnName
(
$name
,
true
);
$quotedName
=
$db
->
quoteColumnName
(
$name
,
true
);
$counters
[
$name
]
=
new
Expression
(
$value
>=
0
?
"
$quotedName
+
$value
"
:
"
$quotedName$value
"
);
$counters
[
$name
]
=
new
Expression
(
$value
>=
0
?
"
$quotedName
+
$value
"
:
"
$quotedName$value
"
);
}
}
$
query
=
new
Query
;
$
command
=
$db
->
createCommand
()
;
$
query
->
update
(
static
::
tableName
(),
$counters
,
$condition
,
$params
);
$
command
->
update
(
static
::
tableName
(),
$counters
,
$condition
,
$params
);
return
$
query
->
createCommand
(
$db
)
->
execute
();
return
$
command
->
execute
();
}
}
/**
/**
...
@@ -224,9 +224,9 @@ abstract class ActiveRecord extends Model
...
@@ -224,9 +224,9 @@ abstract class ActiveRecord extends Model
*/
*/
public
static
function
deleteAll
(
$condition
=
''
,
$params
=
array
())
public
static
function
deleteAll
(
$condition
=
''
,
$params
=
array
())
{
{
$
query
=
new
Query
;
$
command
=
static
::
getDbConnection
()
->
createCommand
()
;
$
query
->
delete
(
static
::
tableName
(),
$condition
,
$params
);
$
command
->
delete
(
static
::
tableName
(),
$condition
,
$params
);
return
$
query
->
createCommand
(
static
::
getDbConnection
())
->
execute
();
return
$
command
->
execute
();
}
}
/**
/**
...
@@ -587,10 +587,9 @@ abstract class ActiveRecord extends Model
...
@@ -587,10 +587,9 @@ abstract class ActiveRecord extends Model
public
function
insert
(
$attributes
=
null
)
public
function
insert
(
$attributes
=
null
)
{
{
if
(
$this
->
beforeInsert
())
{
if
(
$this
->
beforeInsert
())
{
$query
=
new
Query
;
$values
=
$this
->
getChangedAttributes
(
$attributes
);
$values
=
$this
->
getChangedAttributes
(
$attributes
);
$db
=
$this
->
getDbConnection
();
$db
=
$this
->
getDbConnection
();
$command
=
$
query
->
insert
(
$this
->
tableName
(),
$values
)
->
createCommand
(
$db
);
$command
=
$
db
->
createCommand
()
->
insert
(
$this
->
tableName
(),
$values
);
if
(
$command
->
execute
())
{
if
(
$command
->
execute
())
{
$table
=
$this
->
getTableSchema
();
$table
=
$this
->
getTableSchema
();
if
(
$table
->
sequenceName
!==
null
)
{
if
(
$table
->
sequenceName
!==
null
)
{
...
...
tests/unit/framework/db/
ar/
ActiveRecordTest.php
→
tests/unit/framework/db/ActiveRecordTest.php
View file @
d15378ef
<?php
<?php
namespace
yiiunit\framework\db
\ar
;
namespace
yiiunit\framework\db
;
use
yii\db\Query
;
use
yii\db\Query
;
use
yii\db\ActiveQuery
;
use
yii\db\ActiveQuery
;
...
...
tests/unit/framework/db/
dao/
CommandTest.php
→
tests/unit/framework/db/CommandTest.php
View file @
d15378ef
<?php
<?php
namespace
yiiunit\framework\db
\dao
;
namespace
yiiunit\framework\db
;
use
yii\db\Connection
;
use
yii\db\Connection
;
use
yii\db\Command
;
use
yii\db\Command
;
...
@@ -213,4 +213,110 @@ class CommandTest extends \yiiunit\MysqlTestCase
...
@@ -213,4 +213,110 @@ class CommandTest extends \yiiunit\MysqlTestCase
$result
=
$command
->
queryRow
(
array
(),
\PDO
::
FETCH_NUM
);
$result
=
$command
->
queryRow
(
array
(),
\PDO
::
FETCH_NUM
);
$this
->
assertTrue
(
is_array
(
$result
)
&&
isset
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
)
&&
isset
(
$result
[
0
]));
}
}
function
testInsert
()
{
}
function
testUpdate
()
{
}
function
testDelete
()
{
}
function
testCreateTable
()
{
}
function
testRenameTable
()
{
}
function
testDropTable
()
{
}
function
testTruncateTable
()
{
}
function
testAddColumn
()
{
}
function
testDropColumn
()
{
}
function
testRenameColumn
()
{
}
function
testAlterColumn
()
{
}
function
testAddForeignKey
()
{
}
function
testDropForeignKey
()
{
}
function
testCreateIndex
()
{
}
function
testDropIndex
()
{
}
function
testParams
()
{
}
function
testGetSql
()
{
}
function
testCreateCommand
()
{
}
function
testReset
()
{
}
function
testToArray
()
{
}
function
testMergeWith
()
{
}
}
}
\ No newline at end of file
tests/unit/framework/db/
dao/
ConnectionTest.php
→
tests/unit/framework/db/ConnectionTest.php
View file @
d15378ef
<?php
<?php
namespace
yiiunit\framework\db
\dao
;
namespace
yiiunit\framework\db
;
use
yii\db\Connection
;
use
yii\db\Connection
;
...
...
tests/unit/framework/db/
dao/
QueryTest.php
→
tests/unit/framework/db/QueryTest.php
View file @
d15378ef
<?php
<?php
namespace
yiiunit\framework\db
\dao
;
namespace
yiiunit\framework\db
;
use
yii\db\Connection
;
use
yii\db\Connection
;
use
yii\db\Command
;
use
yii\db\Command
;
...
@@ -107,109 +107,4 @@ class QueryTest extends \yiiunit\MysqlTestCase
...
@@ -107,109 +107,4 @@ class QueryTest extends \yiiunit\MysqlTestCase
{
{
}
}
function
testInsert
()
{
}
function
testUpdate
()
{
}
function
testDelete
()
{
}
function
testCreateTable
()
{
}
function
testRenameTable
()
{
}
function
testDropTable
()
{
}
function
testTruncateTable
()
{
}
function
testAddColumn
()
{
}
function
testDropColumn
()
{
}
function
testRenameColumn
()
{
}
function
testAlterColumn
()
{
}
function
testAddForeignKey
()
{
}
function
testDropForeignKey
()
{
}
function
testCreateIndex
()
{
}
function
testDropIndex
()
{
}
function
testParams
()
{
}
function
testGetSql
()
{
}
function
testCreateCommand
()
{
}
function
testReset
()
{
}
function
testToArray
()
{
}
function
testMergeWith
()
{
}
}
}
\ No newline at end of file
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