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
a5c4a0eb
Commit
a5c4a0eb
authored
Jun 02, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted BaseActiveRecord code for better noSQL compatibility
parent
ed041f7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
BaseActiveRecord.php
framework/db/BaseActiveRecord.php
+7
-5
ActiveRecordTestTrait.php
tests/unit/framework/ar/ActiveRecordTestTrait.php
+5
-1
No files found.
framework/db/BaseActiveRecord.php
View file @
a5c4a0eb
...
@@ -1297,8 +1297,6 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
...
@@ -1297,8 +1297,6 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
public
function
unlinkAll
(
$name
,
$delete
=
false
)
public
function
unlinkAll
(
$name
,
$delete
=
false
)
{
{
$relation
=
$this
->
getRelation
(
$name
);
$relation
=
$this
->
getRelation
(
$name
);
/** @var Command $command */
$command
=
static
::
getDb
()
->
createCommand
();
$columns
=
[];
$columns
=
[];
$condition
=
[];
$condition
=
[];
if
(
empty
(
$relation
->
via
))
{
if
(
empty
(
$relation
->
via
))
{
...
@@ -1308,18 +1306,22 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
...
@@ -1308,18 +1306,22 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
foreach
(
$relation
->
link
as
$a
=>
$b
)
{
foreach
(
$relation
->
link
as
$a
=>
$b
)
{
$condition
[
$a
]
=
$this
->
$b
;
$condition
[
$a
]
=
$this
->
$b
;
}
}
$
command
->
delete
(
$viaClass
::
tableName
(),
$condition
)
->
execute
(
);
$
viaClass
::
deleteAll
(
$condition
);
}
else
{
}
else
{
foreach
(
$relation
->
link
as
$a
=>
$b
)
{
foreach
(
$relation
->
link
as
$a
=>
$b
)
{
$columns
[
$a
]
=
null
;
$columns
[
$a
]
=
null
;
$condition
[
$a
]
=
$this
->
$b
;
$condition
[
$a
]
=
$this
->
$b
;
}
}
$
command
->
update
(
$viaClass
::
tableName
(),
$columns
,
$condition
)
->
execute
(
);
$
viaClass
::
updateAll
(
$columns
,
$condition
);
}
}
}
else
{
}
else
{
$viaTable
=
$viaTable
=
reset
(
$relation
->
via
->
from
);
$viaTable
=
reset
(
$relation
->
via
->
from
);
/** @var ActiveQuery $viaRelation */
/** @var ActiveQuery $viaRelation */
$viaRelation
=
$relation
->
via
;
$viaRelation
=
$relation
->
via
;
/** @var Command $command */
$command
=
static
::
getDb
()
->
createCommand
();
if
(
$delete
)
{
if
(
$delete
)
{
foreach
(
$viaRelation
->
link
as
$a
=>
$b
)
{
foreach
(
$viaRelation
->
link
as
$a
=>
$b
)
{
$condition
[
$a
]
=
$this
->
$b
;
$condition
[
$a
]
=
$this
->
$b
;
...
...
tests/unit/framework/ar/ActiveRecordTestTrait.php
View file @
a5c4a0eb
...
@@ -45,6 +45,10 @@ trait ActiveRecordTestTrait
...
@@ -45,6 +45,10 @@ trait ActiveRecordTestTrait
*/
*/
abstract
public
function
getItemClass
();
abstract
public
function
getItemClass
();
abstract
public
function
getOrderWithNullFKClass
();
abstract
public
function
getOrderItemWithNullFKmClass
();
/**
/**
* can be overridden to do things after save()
* can be overridden to do things after save()
*/
*/
...
@@ -724,7 +728,7 @@ trait ActiveRecordTestTrait
...
@@ -724,7 +728,7 @@ trait ActiveRecordTestTrait
public
function
testUnlinkAll
()
public
function
testUnlinkAll
()
{
{
/** @var \yii\db\ActiveRecordInterface $custome
rClass */
/** @var \yii\db\ActiveRecordInterface $custome
wdfsdfdfsfd
$customerClass = $this->getCustomerClass();
$customerClass = $this->getCustomerClass();
/** @var \yii\db\ActiveRecordInterface $orderClass */
/** @var \yii\db\ActiveRecordInterface $orderClass */
$orderClass
=
$this
->
getOrderClass
();
$orderClass
=
$this
->
getOrderClass
();
...
...
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