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
c73cfe14
Commit
c73cfe14
authored
Mar 27, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed inconsistencies with setting old attributes and pks
issue #2892
parent
6f552e0f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
2 deletions
+6
-2
ActiveRecord.php
extensions/mongodb/ActiveRecord.php
+1
-0
ActiveRecord.php
extensions/mongodb/file/ActiveRecord.php
+1
-0
ActiveRecord.php
framework/db/ActiveRecord.php
+1
-1
BaseActiveRecord.php
framework/db/BaseActiveRecord.php
+3
-1
No files found.
extensions/mongodb/ActiveRecord.php
View file @
c73cfe14
...
...
@@ -242,6 +242,7 @@ abstract class ActiveRecord extends BaseActiveRecord
}
$newId
=
static
::
getCollection
()
->
insert
(
$values
);
$this
->
setAttribute
(
'_id'
,
$newId
);
$values
[
'_id'
]
=
$newId
;
$this
->
afterSave
(
true
);
$this
->
setOldAttributes
(
$values
);
...
...
extensions/mongodb/file/ActiveRecord.php
View file @
c73cfe14
...
...
@@ -147,6 +147,7 @@ abstract class ActiveRecord extends \yii\mongodb\ActiveRecord
$newId
=
$collection
->
insert
(
$values
);
}
$this
->
setAttribute
(
'_id'
,
$newId
);
$values
[
'_id'
]
=
$newId
;
$this
->
afterSave
(
true
);
$this
->
setOldAttributes
(
$values
);
...
...
framework/db/ActiveRecord.php
View file @
c73cfe14
...
...
@@ -445,7 +445,7 @@ class ActiveRecord extends BaseActiveRecord
if
(
$this
->
getAttribute
(
$name
)
===
null
)
{
$id
=
$db
->
getLastInsertID
(
$table
->
sequenceName
);
$this
->
setAttribute
(
$name
,
$id
);
$
this
->
setOldAttribute
(
$name
,
$id
)
;
$
values
[
$name
]
=
$id
;
break
;
}
}
...
...
framework/db/BaseActiveRecord.php
View file @
c73cfe14
...
...
@@ -24,7 +24,8 @@ use yii\base\InvalidCallException;
* @property array $dirtyAttributes The changed attribute values (name-value pairs). This property is
* read-only.
* @property boolean $isNewRecord Whether the record is new and should be inserted when calling [[save()]].
* @property array $oldAttributes The old attribute values (name-value pairs).
* @property array $oldAttributes The old attribute values (name-value pairs). Note that the type of this
* property differs in getter and setter. See [[getOldAttributes()]] and [[setOldAttributes()]] for details.
* @property mixed $oldPrimaryKey The old primary key value. An array (column name => column value) is
* returned if the primary key is composite. A string is returned otherwise (null will be returned if the key
* value is null). This property is read-only.
...
...
@@ -477,6 +478,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
* Sets the old attribute values.
* All existing old attribute values will be discarded.
* @param array|null $values old attribute values to be set.
* If set to `null` this record is considered to be [[isNewRecord|new]].
*/
public
function
setOldAttributes
(
$values
)
{
...
...
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