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
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
...
@@ -242,6 +242,7 @@ abstract class ActiveRecord extends BaseActiveRecord
}
}
$newId
=
static
::
getCollection
()
->
insert
(
$values
);
$newId
=
static
::
getCollection
()
->
insert
(
$values
);
$this
->
setAttribute
(
'_id'
,
$newId
);
$this
->
setAttribute
(
'_id'
,
$newId
);
$values
[
'_id'
]
=
$newId
;
$this
->
afterSave
(
true
);
$this
->
afterSave
(
true
);
$this
->
setOldAttributes
(
$values
);
$this
->
setOldAttributes
(
$values
);
...
...
extensions/mongodb/file/ActiveRecord.php
View file @
c73cfe14
...
@@ -147,6 +147,7 @@ abstract class ActiveRecord extends \yii\mongodb\ActiveRecord
...
@@ -147,6 +147,7 @@ abstract class ActiveRecord extends \yii\mongodb\ActiveRecord
$newId
=
$collection
->
insert
(
$values
);
$newId
=
$collection
->
insert
(
$values
);
}
}
$this
->
setAttribute
(
'_id'
,
$newId
);
$this
->
setAttribute
(
'_id'
,
$newId
);
$values
[
'_id'
]
=
$newId
;
$this
->
afterSave
(
true
);
$this
->
afterSave
(
true
);
$this
->
setOldAttributes
(
$values
);
$this
->
setOldAttributes
(
$values
);
...
...
framework/db/ActiveRecord.php
View file @
c73cfe14
...
@@ -445,7 +445,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -445,7 +445,7 @@ class ActiveRecord extends BaseActiveRecord
if
(
$this
->
getAttribute
(
$name
)
===
null
)
{
if
(
$this
->
getAttribute
(
$name
)
===
null
)
{
$id
=
$db
->
getLastInsertID
(
$table
->
sequenceName
);
$id
=
$db
->
getLastInsertID
(
$table
->
sequenceName
);
$this
->
setAttribute
(
$name
,
$id
);
$this
->
setAttribute
(
$name
,
$id
);
$
this
->
setOldAttribute
(
$name
,
$id
)
;
$
values
[
$name
]
=
$id
;
break
;
break
;
}
}
}
}
...
...
framework/db/BaseActiveRecord.php
View file @
c73cfe14
...
@@ -24,7 +24,8 @@ use yii\base\InvalidCallException;
...
@@ -24,7 +24,8 @@ use yii\base\InvalidCallException;
* @property array $dirtyAttributes The changed attribute values (name-value pairs). This property is
* @property array $dirtyAttributes The changed attribute values (name-value pairs). This property is
* read-only.
* read-only.
* @property boolean $isNewRecord Whether the record is new and should be inserted when calling [[save()]].
* @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
* @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
* 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.
* value is null). This property is read-only.
...
@@ -477,6 +478,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
...
@@ -477,6 +478,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
* Sets the old attribute values.
* Sets the old attribute values.
* All existing old attribute values will be discarded.
* All existing old attribute values will be discarded.
* @param array|null $values old attribute values to be set.
* @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
)
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